Example #1
0
function social_ring_get_first_image()
{
    global $post, $posts;
    if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-thumbnail');
        if ($thumbnail) {
            $image = $thumbnail[0];
        }
        // If that's not there, grab the first attached image
    } else {
        $files = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
        if ($files) {
            $keys = array_reverse(array_keys($files));
            $image = image_downsize($keys[0], 'thumbnail');
            $image = $image[0];
        }
    }
    //if there's no attached image, try to grab first image in content
    if (empty($image)) {
        ob_start();
        ob_end_clean();
        $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
        if (!empty($matches[1][0])) {
            $image = $matches[1][0];
        }
    }
    return $image;
}
Example #2
0
function eme_ical_single_event($event, $title_format, $description_format) {
   global $eme_timezone;
   $title = eme_sanitize_ical (eme_replace_placeholders ( $title_format, $event, "text" ));
   $description = eme_sanitize_ical (eme_replace_placeholders ( $description_format, $event, "text" ));
   $html_description = eme_sanitize_ical (eme_replace_placeholders ( $description_format, $event, "html" ),1);

   $event_link = eme_event_url($event);
   $startstring=new ExpressiveDate($event['event_start_date']." ".$event['event_start_time'],$eme_timezone);
   $dtstartdate=$startstring->format("Ymd");
   $dtstarthour=$startstring->format("His");
   //$dtstart=$dtstartdate."T".$dtstarthour."Z";
   // we'll use localtime, so no "Z"
   $dtstart=$dtstartdate."T".$dtstarthour;
   if ($event['event_end_date'] == "")
      $event['event_end_date'] = $event['event_start_date'];
   if ($event['event_end_time'] == "")
      $event['event_end_time'] = $event['event_start_time'];
   $endstring=$event['event_end_date']." ".$event['event_end_time'];
   $endstring=new ExpressiveDate($event['event_end_date']." ".$event['event_end_time'],$eme_timezone);
   $dtenddate=$endstring->format("Ymd");
   $dtendhour=$endstring->format("His");
   //$dtend=$dtenddate."T".$dtendhour."Z";
   // we'll use localtime, so no "Z"
   $dtend=$dtenddate."T".$dtendhour;
   $tzstring = get_option('timezone_string');

   $res = "";
   $res .= "BEGIN:VEVENT\r\n";
   //DTSTAMP must be in UTC format, so adding "Z" as well
   $res .= "DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z\r\n";
   if ($event['event_properties']['all_day']) {
      // ical standard for an all day event: specify only the day, meaning
      // an 'all day' event is flagged as starting at the beginning of one day and lasting until the beginning of the next
      // so it is the same as adding "T000000" as time spec to the start/end datestring
      // But since it "ends" at the beginning of the next day, we should add 24 hours, otherwise the event ends one day too soon
      $dtenddate=$endstring->addOneDay()->format('Ymd');
      $res .= "DTSTART;VALUE=DATE:$dtstartdate\r\n";
      $res .= "DTEND;VALUE=DATE:$dtenddate\r\n";
   } else {
      $res .= "DTSTART;TZID=$tzstring:$dtstart\r\n";
      $res .= "DTEND;TZID=$tzstring:$dtend\r\n";
   }
   $res .= "UID:$dtstart-$dtend-".$event['event_id']."@".$_SERVER['SERVER_NAME']."\r\n";
   $res .= "SUMMARY:$title\r\n";
   $res .= "DESCRIPTION:$description\r\n";
   $res .= "X-ALT-DESC;FMTTYPE=text/html:$html_description\r\n";
   $res .= "URL:$event_link\r\n";
   $res .= "ATTACH:$event_link\r\n";
   if ($event['event_image_id']) {
      $thumb_array = image_downsize( $event['event_image_id'], get_option('eme_thumbnail_size') );
      $thumb_url = $thumb_array[0];
      $res .= "ATTACH:$thumb_url\r\n";
   }
   if (isset($event['location_id']) && $event['location_id']) {
      $location = eme_sanitize_ical (eme_replace_placeholders ( "#_LOCATION, #_ADDRESS, #_TOWN", $event, "text" ));
      $res .= "LOCATION:$location\r\n";
   }
   $res .= "END:VEVENT\r\n";
   return $res;
}
 /** generate new image sizes for old uploads
  * 
  * @param mixed $out
  * @param int $id
  * @param string|array $size
  * @return mixed
  */
 function circleflip_make_missing_intermediate_size($out, $id, $size)
 {
     $skip_sizes = array('full', 'large', 'medium', 'thumbnail', 'thumb');
     if (is_array($size) || in_array($size, $skip_sizes)) {
         return $out;
     }
     // the size exists and the attachment doesn't have a pre-generated file of that size
     // or the intermediate size defintion changed ( during development )
     if (circleflip_intermediate_size_exists($size) && (!circleflip_image_has_intermediate_size($id, $size) || circleflip_has_intermediate_size_changed($id, $size))) {
         // get info registerd by add_image_size
         $size_info = circleflip_get_intermediate_size_info($size);
         // get path to the original file
         $file_path = get_attached_file($id);
         // resize the image
         $resized_file = image_make_intermediate_size($file_path, $size_info['width'], $size_info['height'], $size_info['crop']);
         if ($resized_file) {
             // we have a resized image, get the attachment metadata and add the new size to it
             $metadata = wp_get_attachment_metadata($id);
             $metadata['sizes'][$size] = $resized_file;
             if (wp_update_attachment_metadata($id, $metadata)) {
                 // update succeded, call image_downsize again , DRY
                 return image_downsize($id, $size);
             }
         } else {
             // failed to generate the resized image
             // call image_downsize with `full` to prevent infinit loop
             return image_downsize($id, 'full');
         }
     }
     // pre-existing intermediate size
     return $out;
 }
 /**
  * @param string $ID The attachment ID to retrieve thumbnail from.
  *
  * @return bool|string  False on failure, URL to thumb on success.
  */
 private static function getImageThumbnail($ID)
 {
     $options = DG_Thumber::getOptions();
     $ret = false;
     if ($icon = image_downsize($ID, array($options['width'], $options['height']))) {
         $ret = $icon[0];
     }
     return $ret;
 }
Example #5
0
function the_thumb($size = "medium", $add = "")
{
    global $wpdb, $post;
    $thumb = $wpdb->get_row("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_parent = {$post->ID} AND post_mime_type LIKE 'image%' ORDER BY menu_order");
    if (!empty($thumb)) {
        $image = image_downsize($thumb->ID, $size);
        print "<img src='{$image[0]}' alt='{$thumb->post_title}' {$add} />";
    }
}
Example #6
0
    /**
     * Post gGallery with lightbox ready for use.
     */
    function theme_gallery_lightbox($post_id)
    {
        global $post;
        $thumbnail_ID = get_post_thumbnail_id();
        $images = get_children(array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
        if ($images) {
            ?>

        <ul class="gallery-list" data-action="gallery-<?php 
            the_ID();
            ?>
" data-ui-component="gallery">

        <?php 
            foreach ($images as $attachment_id => $image) {
                if ($image->ID != $thumbnail_ID) {
                    $img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
                    //alt
                    if ($img_alt == '') {
                        $img_alt = $img_title;
                    }
                    $big_array = image_downsize($image->ID, 'full');
                    $img_url = $big_array[0];
                    ?>

            <li class="gallery-item" data-src="<?php 
                    echo $image_url;
                    ?>
" data-html="<div class='gallery-caption'><h4 class='text-inverse'><?php 
                    echo the_title();
                    ?>
</h4><?php 
                    echo the_content();
                    ?>
</div>">
                <img src="<?php 
                    echo $img_url;
                    ?>
" alt="<?php 
                    echo $img_alt;
                    ?>
" title="<?php 
                    echo $img_title;
                    ?>
" />
            </li>

            <?php 
                }
                ?>
            <?php 
            }
            ?>
        </ul>
        <?php 
        }
    }
/**
 * Return a source size attribute for an image from an array of values.
 *
 * @since 2.2.0
 *
 * @param int    $id   Image attachment ID.
 * @param string $size Optional. Name of image size. Default value: 'medium'.
 * @param array  $args {
 *     Optional. Arguments to retrieve posts.
 *
 *     @type array|string $sizes An array or string containing of size information.
 *     @type int          $width A single width value used in the default `sizes` string.
 * }
 * @return string|bool A valid source size value for use in a 'sizes' attribute or false.
 */
function tevkori_get_sizes($id, $size = 'medium', $args = null)
{
    // Try to get the image width from `$args` before calling `image_downsize()`.
    if (is_array($args) && !empty($args['width'])) {
        $img_width = (int) $args['width'];
    } elseif ($img = image_downsize($id, $size)) {
        $img_width = $img[1];
    }
    // Bail early if ``$image_width` isn't set.
    if (!$img_width) {
        return false;
    }
    // Set the image width in pixels.
    $img_width = $img_width . 'px';
    // Set up our default values.
    $defaults = array('sizes' => array(array('size_value' => '100vw', 'mq_value' => $img_width, 'mq_name' => 'max-width'), array('size_value' => $img_width)));
    $args = wp_parse_args($args, $defaults);
    /**
     * Filter arguments used to create 'sizes' attribute.
     *
     * @since 2.4.0
     *
     * @param array   $args  An array of arguments used to create a 'sizes' attribute.
     * @param int     $id    Post ID of the original image.
     * @param string  $size  Name of the image size being used.
     */
    $args = apply_filters('tevkori_image_sizes_args', $args, $id, $size);
    // If sizes is passed as a string, just use the string.
    if (is_string($args['sizes'])) {
        $size_list = $args['sizes'];
        // Otherwise, breakdown the array and build a sizes string.
    } elseif (is_array($args['sizes'])) {
        $size_list = '';
        foreach ($args['sizes'] as $size) {
            // Use 100vw as the size value unless something else is specified.
            $size_value = $size['size_value'] ? $size['size_value'] : '100vw';
            // If a media length is specified, build the media query.
            if (!empty($size['mq_value'])) {
                $media_length = $size['mq_value'];
                // Use max-width as the media condition unless min-width is specified.
                $media_condition = !empty($size['mq_name']) ? $size['mq_name'] : 'max-width';
                // If a media_length was set, create the media query.
                $media_query = '(' . $media_condition . ": " . $media_length . ') ';
            } else {
                // If not meda length was set, $media_query is blank.
                $media_query = '';
            }
            // Add to the source size list string.
            $size_list .= $media_query . $size_value . ', ';
        }
        // Remove the trailing comma and space from the end of the string.
        $size_list = substr($size_list, 0, -2);
    }
    // If $size_list is defined set the string, otherwise set false.
    return $size_list ? $size_list : false;
}
function eazy_css_slider_image_size($downsize, $id, $size)
{
    if (!is_admin() || !get_current_screen() || 'edit' !== get_current_screen()->parent_base) {
        return $downsize;
    }
    remove_filter('image_downsize', __FUNCTION__, 10, 3);
    // settings can be thumbnail, medium, large, full
    $image = image_downsize($id, 'medium');
    add_filter('image_downsize', __FUNCTION__, 10, 3);
    return $image;
}
function nerdy_get_images($size = 'thumbnail', $limit = '0', $offset = '0')
{
    global $post;
    $images = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    if ($images) {
        $num_of_images = count($images);
        if ($offset > 0) {
            $start = $offset--;
        } else {
            $start = 0;
        }
        if ($limit > 0) {
            $stop = $limit + $start;
        } else {
            $stop = $num_of_images;
        }
        $i = 0;
        foreach ($images as $image) {
            if ($start <= $i and $i < $stop) {
                $img_title = $image->post_title;
                // title.
                $img_description = $image->post_content;
                // description.
                $img_caption = $image->post_excerpt;
                // caption.
                $img_url = wp_get_attachment_url($image->ID);
                // url of the full size image.
                $preview_array = image_downsize($image->ID, $size);
                $img_preview = $preview_array[0];
                // thumbnail or medium image to use for preview.
                ?>
            <li>
                <a href="<?php 
                echo $img_url;
                ?>
"><img src="<?php 
                echo $img_preview;
                ?>
" alt="<?php 
                echo $img_caption;
                ?>
" title="<?php 
                echo $img_title;
                ?>
"></a>
            </li>
            <?php 
            }
            $i++;
        }
    }
}
Example #10
0
 function getImageTag($id, $alt, $title, $align, $size = 'medium', $attrs = array())
 {
     list($img_src, $width, $height) = image_downsize($id, $size);
     $hwstring = image_hwstring($width, $height);
     $class = 'align' . esc_attr($align) . ' size-' . esc_attr($size) . ' wp-image-' . $id;
     $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
     $attrs_fields = '';
     foreach ($attrs as $name => $attr) {
         $attrs_fields .= ' ' . $name . '="' . esc_attr($attr) . '" ';
     }
     $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title) . '" ' . $hwstring . 'class="' . $class . '" ' . $attrs_fields . ' />';
     return $html;
 }
Example #11
0
 public function getImageSquareSize($img_id, $img_size)
 {
     if (preg_match_all('/(\\d+)x(\\d+)/', $img_size, $sizes)) {
         $exact_size = array('width' => isset($sizes[1][0]) ? $sizes[1][0] : '0', 'height' => isset($sizes[2][0]) ? $sizes[2][0] : '0');
     } else {
         $image_downsize = image_downsize($img_id, $img_size);
         $exact_size = array('width' => $image_downsize[1], 'height' => $image_downsize[2]);
     }
     if (isset($exact_size['width']) && (int) $exact_size['width'] !== (int) $exact_size['height']) {
         $img_size = (int) $exact_size['width'] > (int) $exact_size['height'] ? $exact_size['height'] . 'x' . $exact_size['height'] : $exact_size['width'] . 'x' . $exact_size['width'];
     }
     return $img_size;
 }
Example #12
0
/**
 * Convert a track into the format expected by the Cue plugin.
 *
 * @since 1.5.0
 *
 * @param int|WP_Post $post Post object or ID.
 * @return object Track object expected by Cue.
 */
function get_audiotheme_playlist_track($post = 0)
{
    $post = get_post($post);
    $track = new stdClass();
    $track->id = $post->ID;
    $track->artist = get_audiotheme_track_artist($post->ID);
    $track->audioUrl = get_audiotheme_track_file_url($post->ID);
    $track->title = get_the_title($post->ID);
    if ($thumbnail_id = get_audiotheme_track_thumbnail_id($post->ID)) {
        $size = apply_filters('cue_artwork_size', array(300, 300));
        $image = image_downsize($thumbnail_id, $size);
        $track->artworkUrl = $image[0];
    }
    return $track;
}
Example #13
0
/**
 * argo_get_image_tag(): Renders an <img /> tag for attachments, scaling it
 * to $size and guaranteeing that it's not wider than the content well.
 *
 * This is largely taken from get_image_tag() in wp-includes/media.php.
 */
function argo_get_image_tag($html, $id, $alt, $title, $align, $size)
{
    // Never allow an image wider than the LARGE_WIDTH
    if ($size == 'full') {
        list($img_src, $width, $height) = wp_get_attachment_image_src($id, $size);
        if ($width > LARGE_WIDTH) {
            $size = 'large';
        }
    }
    list($img_src, $width, $height) = image_downsize($id, $size);
    $hwstring = image_hwstring($width, $height);
    // XXX: may not need all these classes
    $class = 'align' . esc_attr($align) . ' size-' . esc_attr($size) . ' wp-image-' . $id;
    $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
    $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title) . '" ' . $hwstring . 'class="' . $class . '" />';
    return $html;
}
Example #14
0
function nerdy_project_slide_get_images($size = 'thumbnail', $limit = '0', $offset = '0')
{
    global $post;
    $images = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    if ($images) {
        $num_of_images = count($images);
        if ($offset > 0) {
            $start = $offset--;
        } else {
            $start = 0;
        }
        if ($limit > 0) {
            $stop = $limit + $start;
        } else {
            $stop = $num_of_images;
        }
        $i = 0;
        foreach ($images as $image) {
            if ($start <= $i and $i < $stop) {
                $img_title = $image->post_title;
                // title.
                $img_description = $image->post_content;
                // description.
                $img_caption = $image->post_excerpt;
                // caption.
                $img_url = wp_get_attachment_url($image->ID);
                // url of the full size image.
                $preview_array = image_downsize($image->ID, $size);
                $img_preview = $preview_array[0];
                // thumbnail or medium image to use for preview.
                ///////////////////////////////////////////////////////////
                // This is where you'd create your custom image/link/whatever tag using the variables above.
                // This is an example of a basic image tag using this method.
                ?>
        <div><img src="<?php 
                echo $img_preview;
                ?>
" /></div>
			<?php 
                // End custom image tag. Do not edit below here.
                ///////////////////////////////////////////////////////////
            }
            $i++;
        }
    }
}
 function get_src($size = '')
 {
     if (isset($this->abs_url)) {
         return $this->abs_url;
     }
     if ($size && is_string($size) && isset($this->sizes[$size])) {
         $image = image_downsize($this->ID, $size);
         return reset($image);
     }
     if (!isset($this->file) && isset($this->_wp_attached_file)) {
         $this->file = $this->_wp_attached_file;
     }
     if (!isset($this->file)) {
         return false;
     }
     $dir = wp_upload_dir();
     $base = $dir["baseurl"];
     return trailingslashit($base) . $this->file;
 }
/**
 * Return a source size attribute for an image from an array of values.
 *
 * @since 2.2.0
 *
 * @param int $id 			Image attacment ID.
 * @param string $size	Optional. Name of image size. Default value: 'thumbnail'.
 * @param array $args {
 *     Optional. Arguments to retrieve posts.
 *
 *     @type array|string 	$sizes     An array or string containing of size information.
 * }
 * @return string|bool A valid source size value for use in a 'sizes' attribute or false.
 */
function tevkori_get_sizes($id, $size = 'thumbnail', $args = null)
{
    // See which image is being returned and bail if none is found
    if (!($image = image_downsize($id, $size))) {
        return false;
    }
    // Get the image width
    $img_width = $image[1] . 'px';
    // Set up our default values
    $defaults = array('sizes' => array(array('size_value' => '100vw', 'mq_value' => $img_width, 'mq_name' => 'max-width'), array('size_value' => $img_width)));
    $args = wp_parse_args($args, $defaults);
    // If sizes is passed as a string, just use the string
    if (is_string($args['sizes'])) {
        $size_list = $args['sizes'];
        // Otherwise, breakdown the array and build a sizes string
    } elseif (is_array($args['sizes'])) {
        $size_list = '';
        foreach ($args['sizes'] as $size) {
            // Use 100vw as the size value unless something else is specified.
            $size_value = $size['size_value'] ? $size['size_value'] : '100vw';
            // If a media length is specified, build the media query.
            if (!empty($size['mq_value'])) {
                $media_length = $size['mq_value'];
                // Use max-width as the media condition unless min-width is specified.
                $media_condition = !empty($size['mq_name']) ? $size['mq_name'] : 'max-width';
                // If a media_length was set, create the media query.
                $media_query = '(' . $media_condition . ": " . $media_length . ') ';
            } else {
                // If not meda length was set, $media_query is blank
                $media_query = '';
            }
            // Add to the source size list string.
            $size_list .= $media_query . $size_value . ', ';
        }
        // Remove the trailing comma and space from the end of the string.
        $size_list = substr($size_list, 0, -2);
    }
    // If $size_list is defined set the string, otherwise set false.
    $size_string = $size_list ? $size_list : false;
    return $size_string;
}
 function wphidpi_image_downsize($out, $id, $size)
 {
     $orig_size = $size;
     if (!wphidpi_enabled()) {
         return false;
     }
     if (is_array($size)) {
         foreach ($size as &$component) {
             $component = intval($component) * 2;
         }
     } else {
         if (strtolower($size) != 'full') {
             $size = $size . wphidpi_suffix();
         }
     }
     remove_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
     $downsize = image_downsize($id, $size);
     add_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
     // If downsize isn't false  and this is an intermediate
     if ($downsize && $downsize[3]) {
         $downsize[1] = intval($downsize[1]) / 2;
         $downsize[2] = intval($downsize[2]) / 2;
     } else {
         if ($downsize && $size != 'full') {
             // Full sized but no 2x, serve with original dimensions but full sized source
             $original_url = $downsize[0];
             remove_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
             $downsize_orig = image_downsize($id, $orig_size);
             add_filter('image_downsize', 'wphidpi_image_downsize', 10, 3);
             if ($downsize_orig) {
                 $downsize = $downsize_orig;
                 $downsize[0] = $original_url;
             }
         }
     }
     return $downsize;
 }
function wppb_front_end_register($atts)
{
    ob_start();
    global $current_user;
    global $wp_roles;
    global $wpdb;
    global $error;
    global $wppb_shortcode_on_front;
    //get required and shown fields
    $wppb_defaultOptions = get_option('wppb_default_settings');
    //get "login with" setting
    $wppb_generalSettings = get_option('wppb_general_settings');
    $wppb_shortcode_on_front = true;
    $agreed = true;
    $new_user = '******';
    $multisite_message = false;
    $registerFilterArray = array();
    $registerFilterArray2 = array();
    $uploadExt = array();
    $extraFieldsErrorHolder = array();
    //we will use this array to store the ID's of the extra-fields left uncompleted
    get_currentuserinfo();
    /* variables used to verify if all required fields were submitted*/
    $firstnameComplete = 'yes';
    $lastnameComplete = 'yes';
    $nicknameComplete = 'yes';
    $websiteComplete = 'yes';
    $aimComplete = 'yes';
    $yahooComplete = 'yes';
    $jabberComplete = 'yes';
    $bioComplete = 'yes';
    /* END variables used to verify if all required fields were submitted*/
    /* Check if users can register. */
    $registration = get_option('users_can_register');
    $registration = apply_filters('wppb_register_setting_override', $registration);
    //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error']
    if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
        $registerFilterArray['noPostError'] = '<p class="error">' . sprintf(__('The information size you were trying to submit was larger than %1$sb!<br/>This is usually caused by a large file(s) trying to be uploaded.<br/>Since it was also larger than %2$sb no additional information is available.<br/>The user was NOT created!', 'profilebuilder'), WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA) . '</p>';
        echo $registerFilterArray['noPostError'] = apply_filters('wppb_register_no_post_error_message', $registerFilterArray['noPostError'], WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA);
    }
    /* If user registered, input info. */
    if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'adduser' && wp_verify_nonce($_POST['register_nonce_field'], 'verify_true_registration') && $_POST['formName'] == 'register') {
        //global $wp_roles;
        //get value sent in the shortcode as parameter, use default if not set
        $default_role = get_option('default_role');
        extract(shortcode_atts(array('role' => $default_role), $atts));
        //check if the specified role exists in the database, else fall back to the "safe-zone"
        $aprovedRole = $role == $default_role || get_role($role) ? $role : $default_role;
        /* preset the values in case some are not submitted */
        $user_pass = '';
        if (isset($_POST['passw1'])) {
            $user_pass = esc_attr($_POST['passw1']);
        }
        $email = '';
        if (isset($_POST['email'])) {
            $email = trim($_POST['email']);
        }
        if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            $user_name = wppb_generate_random_username($email);
        } else {
            $user_name = '';
            if (isset($_POST['user_name'])) {
                $user_name = trim($_POST['user_name']);
            }
        }
        $first_name = '';
        if (isset($_POST['first_name'])) {
            $first_name = trim($_POST['first_name']);
        }
        $last_name = '';
        if (isset($_POST['last_name'])) {
            $last_name = trim($_POST['last_name']);
        }
        $nickname = '';
        if (isset($_POST['nickname'])) {
            //the field is filled by the user upon registration
            $nickname = trim($_POST['nickname']);
        } elseif (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            //in case the nickname field is hidden, and the login with email is active
            $nickname = $email;
        } else {
            //in case the nickname field is hidden, but login is done with username
            $nickname = $user_name;
        }
        $website = '';
        if (isset($_POST['website'])) {
            $website = trim($_POST['website']);
        }
        $aim = '';
        if (isset($_POST['aim'])) {
            $aim = trim($_POST['aim']);
        }
        $yim = '';
        if (isset($_POST['yim'])) {
            $yim = trim($_POST['yim']);
        }
        $jabber = '';
        if (isset($_POST['jabber'])) {
            $jabber = trim($_POST['jabber']);
        }
        $description = '';
        if (isset($_POST['description'])) {
            $description = trim($_POST['description']);
        }
        /* use filters to modify (if needed) the posted data before creating the user-data */
        $user_pass = apply_filters('wppb_register_posted_password', $user_pass);
        $user_name = apply_filters('wppb_register_posted_username', $user_name);
        $first_name = apply_filters('wppb_register_posted_first_name', $first_name);
        $last_name = apply_filters('wppb_register_posted_last_name', $last_name);
        $nickname = apply_filters('wppb_register_posted_nickname', $nickname);
        $email = apply_filters('wppb_register_posted_email', $email);
        $website = apply_filters('wppb_register_posted_website', $website);
        $aim = apply_filters('wppb_register_posted_aim', $aim);
        $yim = apply_filters('wppb_register_posted_yahoo', $yim);
        $jabber = apply_filters('wppb_register_posted_jabber', $jabber);
        $description = apply_filters('wppb_register_posted_bio', $description);
        /* END use filters to modify (if needed) the posted data before creating the user-data */
        $userdata = array('user_pass' => $user_pass, 'user_login' => esc_attr($user_name), 'first_name' => esc_attr($first_name), 'last_name' => esc_attr($last_name), 'nickname' => esc_attr($nickname), 'user_email' => esc_attr($email), 'user_url' => esc_attr($website), 'aim' => esc_attr($aim), 'yim' => esc_attr($yim), 'jabber' => esc_attr($jabber), 'description' => esc_attr($description), 'role' => $aprovedRole);
        $userdata = apply_filters('wppb_register_userdata', $userdata);
        //check if the user agreed to the terms and conditions (if it was set)
        $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
        if (file_exists($wppb_premium . 'extra.fields.php')) {
            $wppbFetchArray = get_option('wppb_custom_fields');
            foreach ($wppbFetchArray as $key => $value) {
                switch ($value['item_type']) {
                    case "agreeToTerms":
                        $agreed = false;
                        if (isset($_POST[$value['item_type'] . $value['id']]) && $_POST[$value['item_type'] . $value['id']] == 'agree') {
                            $agreed = true;
                        }
                        break;
                }
                // add filters for all the custom fields
                $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_register_' . $value['item_type'] . $value['id'] . '_general_filter', $_POST[$value['item_type'] . $value['id']]);
            }
        }
        $registerFilterArray['extraError'] = '';
        //this is for creating extra error message and bypassing registration
        $registerFilterArray['extraError'] = apply_filters('wppb_register_extra_error', $registerFilterArray['extraError']);
        /* check if all the required fields were completed */
        if ($wppb_defaultOptions['firstname'] == 'show') {
            if ($wppb_defaultOptions['firstnameRequired'] == 'yes' && trim($_POST['first_name']) == '') {
                $firstnameComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['lastname'] == 'show') {
            if ($wppb_defaultOptions['lastnameRequired'] == 'yes' && trim($_POST['last_name']) == '') {
                $lastnameComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['nickname'] == 'show') {
            if ($wppb_defaultOptions['nicknameRequired'] == 'yes' && trim($_POST['nickname']) == '') {
                $nicknameComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['website'] == 'show') {
            if ($wppb_defaultOptions['websiteRequired'] == 'yes' && trim($_POST['website']) == '') {
                $websiteComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['aim'] == 'show') {
            if ($wppb_defaultOptions['aimRequired'] == 'yes' && trim($_POST['aim']) == '') {
                $aimComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['yahoo'] == 'show') {
            if ($wppb_defaultOptions['yahooRequired'] == 'yes' && trim($_POST['yahoo']) == '') {
                $yahooComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['jabber'] == 'show') {
            if ($wppb_defaultOptions['jabberRequired'] == 'yes' && trim($_POST['jabber']) == '') {
                $jabberComplete = 'no';
            }
        }
        if ($wppb_defaultOptions['bio'] == 'show') {
            if ($wppb_defaultOptions['bioRequired'] == 'yes' && trim($_POST['description']) == '') {
                $bioComplete = 'no';
            }
        }
        // check the extra fields also
        $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
        if (file_exists($wppb_premium . 'extra.fields.php')) {
            $wppbFetchArray = get_option('wppb_custom_fields');
            foreach ($wppbFetchArray as $key => $value) {
                switch ($value['item_type']) {
                    case "input":
                        $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_register_input_custom_field_' . $value['id'], $_POST[$value['item_type'] . $value['id']]);
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "checkbox":
                        $checkboxOption = '';
                        $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']);
                        $checkboxValue = explode(',', $value['item_options']);
                        foreach ($checkboxValue as $thisValue) {
                            $thisValue = str_replace(' ', '#@space@#', $thisValue);
                            //we need to escape the space-codification we sent earlier in the post
                            if (isset($_POST[$thisValue . $value['id']])) {
                                $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]);
                                $checkboxOption = $checkboxOption . $localValue . ',';
                            }
                        }
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($checkboxOption) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "radio":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "select":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "countrySelect":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "timeZone":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "datepicker":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "textarea":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if (trim($_POST[$value['item_type'] . $value['id']]) == '') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                    case "upload":
                        $uploadedfile = $value['item_type'] . $value['id'];
                        if (basename($_FILES[$uploadedfile]['name']) == '') {
                            if (isset($value['item_required'])) {
                                if ($value['item_required'] == 'yes') {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        } elseif (basename($_FILES[$uploadedfile]['name']) != '') {
                            //get allowed file types
                            if ($value['item_options'] != NULL || $value['item_options'] != '') {
                                $allFiles = false;
                                $extensions = explode(',', $value['item_options']);
                                foreach ($extensions as $key2 => $value2) {
                                    $extensions[$key2] = trim($value2);
                                }
                            } else {
                                $allFiles = true;
                            }
                            $thisFileExtStart = strrpos($_FILES[$uploadedfile]['name'], '.');
                            $thisFileExt = substr($_FILES[$uploadedfile]['name'], $thisFileExtStart);
                            if ($allFiles == false && !in_array($thisFileExt, $extensions)) {
                                array_push($uploadExt, basename($_FILES[$uploadedfile]['name']));
                                $allowedExtensions = '';
                                (int) ($nrOfExt = count($extensions) - 2);
                                foreach ($extensions as $key2 => $value2) {
                                    $allowedExtensions .= $value2;
                                    if ($key2 <= $nrOfExt) {
                                        $allowedExtensions .= ', ';
                                    }
                                }
                            }
                        }
                        break;
                    case "avatar":
                        $uploadedfile = $value['item_type'] . $value['id'];
                        if (basename($_FILES[$uploadedfile]['name']) == '') {
                            if ($_FILES[$uploadedfile]['type'] != 'image/jpeg' || $_FILES[$uploadedfile]['type'] != 'image/jpg' || $_FILES[$uploadedfile]['type'] != 'image/png' || $_FILES[$uploadedfile]['type'] != 'image/bmp' || $_FILES[$uploadedfile]['type'] != 'image/pjpeg' || $_FILES[$uploadedfile]['type'] != 'image/x-png') {
                                if (isset($value['item_required'])) {
                                    if ($value['item_required'] == 'yes') {
                                        array_push($extraFieldsErrorHolder, $value['id']);
                                    }
                                }
                            }
                        }
                        break;
                    case "agreeToTerms":
                        if (isset($value['item_required'])) {
                            if ($value['item_required'] == 'yes') {
                                if ($_POST[$value['item_type'] . $value['id']] == NULL) {
                                    array_push($extraFieldsErrorHolder, $value['id']);
                                }
                            }
                        }
                        break;
                }
            }
        }
        /* END check if all the required fields were completed */
        if ($registerFilterArray['extraError'] != '') {
            $error = $registerFilterArray['extraError'];
        } elseif (!$userdata['user_login']) {
            if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            } else {
                $error = apply_filters('wppb_register_userlogin_error1', __('A username is required for registration.', 'profilebuilder'));
            }
        } elseif (username_exists($userdata['user_login'])) {
            if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            } else {
                $error = apply_filters('wppb_register_userlogin_error2', __('Sorry, that username already exists!', 'profilebuilder'));
            }
        } elseif (!is_email($userdata['user_email'], true)) {
            $error = apply_filters('wppb_register_useremail_error1', __('You must enter a valid email address.', 'profilebuilder'));
        } elseif (email_exists($userdata['user_email'])) {
            $error = apply_filters('wppb_register_useremail_error2', __('Sorry, that email address is already used!', 'profilebuilder'));
        } elseif (empty($_POST['passw1']) || empty($_POST['passw2']) || $_POST['passw1'] != $_POST['passw2']) {
            if (empty($_POST['passw1']) || empty($_POST['passw2'])) {
                //verify if the user has completed both password fields
                $error = apply_filters('wppb_register_userpass_error1', __('You didn\'t complete one of the password-fields!', 'profilebuilder'));
            } elseif ($_POST['passw1'] != $_POST['passw2']) {
                //verify if the the password and the retyped password are a match
                $error = apply_filters('wppb_register_userpass_error2', __('The entered passwords don\'t match!', 'profilebuilder'));
            }
        } elseif (count($uploadExt) > 0) {
            $error = '<p class="semi-saved">' . __('There was an error while trying to upload the following attachment(s)', 'profilebuilder') . ': <span class="error">';
            foreach ($uploadExt as $key5 => $name5) {
                $lastOne++;
                $error .= $name5;
                if (count($uploadExt) - $lastOne > 0) {
                    $error .= ';<span style="padding-left:10px"></span>';
                }
            }
            $error .= '</span><br/>' . __('Only files with the following extension(s) can be uploaded:', 'profilebuilder') . ' <span class="error">' . $allowedExtensions . '</span><br/><span class="error">' . __('The account was NOT created!', 'profilebuilder') . '</span>
					</p>';
        } elseif ($agreed == false) {
            $error = __('You must agree to the terms and conditions before registering!', 'profilebuilder');
        } elseif ($firstnameComplete == 'no' || $lastnameComplete == 'no' || $nicknameComplete == 'no' || $websiteComplete == 'no' || $aimComplete == 'no' || $yahooComplete == 'no' || $jabberComplete == 'no' || $bioComplete == 'no' || !empty($extraFieldsErrorHolder)) {
            $error = __('The account was NOT created!', 'profilebuilder') . '<br/>' . __('(Several required fields were left uncompleted)', 'profilebuilder');
        } else {
            $registered_name = $_POST['user_name'];
            //register the user normally if it is not a multi-site installation
            if (!is_multisite()) {
                $wppb_generalSettings = get_option('wppb_general_settings');
                if ($wppb_generalSettings['emailConfirmation'] == 'yes') {
                    $foundError = false;
                    if (is_multisite()) {
                        $userSignup = $wpdb->get_results("SELECT * FROM {$wpdb->signups} WHERE user_login='******'user_login'] . "' OR user_email='" . $userdata['user_email'] . "'");
                    } else {
                        $userSignup = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_login='******'user_login'] . "' OR user_email='" . $userdata['user_email'] . "'");
                    }
                    if (trim($userSignup[0]->user_login) == $userdata['user_login']) {
                        $foundError = true;
                        $error = __('This username is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
                    } elseif (trim($userSignup[0]->user_email) == $userdata['user_email']) {
                        $foundError = true;
                        $error = __('This email address is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
                    }
                    if ($foundError) {
                    } else {
                        $new_user = '******';
                        $multisite_message = true;
                        $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']);
                        $meta = wppb_add_custom_field_values($_POST, $meta);
                        wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta);
                    }
                } else {
                    $new_user = wp_insert_user($userdata);
                    /* add the extra profile information */
                    $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
                    if (file_exists($wppb_premium . 'extra.fields.php')) {
                        $wppbFetchArray = get_option('wppb_custom_fields');
                        foreach ($wppbFetchArray as $key => $value) {
                            switch ($value['item_type']) {
                                case "input":
                                    add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']]));
                                    break;
                                case "hiddenInput":
                                    add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']]));
                                    break;
                                case "checkbox":
                                    $checkboxOption = '';
                                    $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']);
                                    $checkboxValue = explode(',', $value['item_options']);
                                    foreach ($checkboxValue as $thisValue) {
                                        $thisValue = str_replace(' ', '#@space@#', $thisValue);
                                        //we need to escape the space-codification we sent earlier in the post
                                        if (isset($_POST[$thisValue . $value['id']])) {
                                            $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]);
                                            $checkboxOption = $checkboxOption . $localValue . ',';
                                        }
                                    }
                                    add_user_meta($new_user, $value['item_metaName'], $checkboxOption);
                                    break;
                                case "radio":
                                    add_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]);
                                    break;
                                case "select":
                                    add_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]);
                                    break;
                                case "countrySelect":
                                    update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]);
                                    break;
                                case "timeZone":
                                    update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]);
                                    break;
                                case "datepicker":
                                    update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]);
                                    break;
                                case "textarea":
                                    add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']]));
                                    break;
                                case "upload":
                                    $uploadedfile = $value['item_type'] . $value['id'];
                                    //first we need to verify if we don't try to upload a 0b or 0 length file
                                    if (basename($_FILES[$uploadedfile]['name']) != '') {
                                        //second we need to verify if the uploaded file size is less then the set file size in php.ini
                                        if ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0) {
                                            //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
                                            $fileName = basename($_FILES[$uploadedfile]['name']);
                                            $finalFileName = '';
                                            for ($i = 0; $i < strlen($fileName); $i++) {
                                                if ($fileName[$i] == "'") {
                                                    $finalFileName .= '`';
                                                } else {
                                                    $finalFileName .= $fileName[$i];
                                                }
                                            }
                                            //create the target path for uploading
                                            $wpUploadPath = wp_upload_dir();
                                            // Array of key => value pairs
                                            $target_path = $wpUploadPath['basedir'] . "/profile_builder/attachments/";
                                            $target_path = $target_path . 'userID_' . $new_user . '_attachment_' . $finalFileName;
                                            if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) {
                                                //$upFile = get_bloginfo('home').'/'.$target_path;
                                                $upFile = $wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $new_user . '_attachment_' . $finalFileName;
                                                add_user_meta($new_user, $value['item_metaName'], $upFile);
                                                $pictureUpload = 'yes';
                                            }
                                        }
                                    }
                                    break;
                                case "avatar":
                                    $uploadedfile = $value['item_type'] . $value['id'];
                                    $wpUploadPath = wp_upload_dir();
                                    // Array of key => value pairs
                                    $target_path_original = $wpUploadPath['basedir'] . "/profile_builder/avatars/";
                                    $fileName = $_FILES[$uploadedfile]['name'];
                                    $finalFileName = '';
                                    for ($i = 0; $i < strlen($fileName); $i++) {
                                        if ($fileName[$i] == "'") {
                                            $finalFileName .= '`';
                                        } elseif ($fileName[$i] == ' ') {
                                            $finalFileName .= '_';
                                        } else {
                                            $finalFileName .= $fileName[$i];
                                        }
                                    }
                                    $fileName = $finalFileName;
                                    $target_path = $target_path_original . 'userID_' . $new_user . '_originalAvatar_' . $fileName;
                                    /* when trying to upload file, be sure it's one of the accepted image file-types */
                                    if (($_FILES[$uploadedfile]['type'] == 'image/jpeg' || $_FILES[$uploadedfile]['type'] == 'image/jpg' || $_FILES[$uploadedfile]['type'] == 'image/png' || $_FILES[$uploadedfile]['type'] == 'image/bmp' || $_FILES[$uploadedfile]['type'] == 'image/pjpeg' || $_FILES[$uploadedfile]['type'] == 'image/x-png') && ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0)) {
                                        $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null);
                                        $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit');
                                        $attach_id = wp_insert_attachment($attachment, $target_path);
                                        $upFile = image_downsize($attach_id, 'thumbnail');
                                        $upFile = $upFile[0];
                                        //if file upload succeded
                                        if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) {
                                            add_user_meta($new_user, $value['item_metaName'], $upFile);
                                            wppb_resize_avatar($new_user);
                                            $avatarUpload = 'yes';
                                        } else {
                                            $avatarUpload = 'no';
                                        }
                                    }
                                    if ($_FILES[$uploadedfile]['type'] == '') {
                                        $avatarUpload = 'yes';
                                    }
                                    break;
                            }
                        }
                    }
                    // if admin approval is activated, then block the user untill he gets approved
                    $wppb_generalSettings = get_option('wppb_general_settings', 'not_found');
                    if ($wppb_generalSettings != 'not_found') {
                        if ($wppb_generalSettings['adminApproval'] == 'yes') {
                            wp_set_object_terms($new_user, array('unapproved'), 'user_status', false);
                            clean_object_term_cache($new_user, 'user_status');
                        }
                    }
                    // send an email to the admin, and - if selected - to the user also.
                    $bloginfo = get_bloginfo('name');
                    $sentEmailStatus = wppb_notify_user_registration_email($bloginfo, esc_attr($_POST['user_name']), esc_attr($_POST['email']), $_POST['send_credentials_via_email'], $_POST['passw1'], $wppb_generalSettings['adminApproval']);
                }
            } elseif (is_multisite()) {
                //validate username and email
                $validationRes = wpmu_validate_user_signup($userdata['user_login'], $userdata['user_email']);
                $error = apply_filters('wppb_register_wpmu_registration_error', $validationRes['errors']->get_error_message());
                if (trim($error) != '') {
                } else {
                    $new_user = '******';
                    $multisite_message = true;
                    $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']);
                    $meta = wppb_add_custom_field_values($_POST, $meta);
                    wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta);
                }
            }
        }
    }
    ?>
	<div class="wppb_holder" id="wppb_register">
<?php 
    if (is_user_logged_in() && !current_user_can('create_users')) {
        global $user_ID;
        $login = get_userdata($user_ID);
        if ($login->display_name == '') {
            $login->display_name = $login->user_login;
        }
        $registerFilterArray['loginLogoutError'] = '
				<p class="log-in-out alert">' . __('You are logged in as', 'profilebuilder') . ' <a href="' . get_author_posts_url($login->ID) . '" title="' . $login->display_name . '">' . $login->display_name . '</a>. ' . __('You don\'t need another account.', 'profilebuilder') . ' <a href="' . wp_logout_url(get_permalink()) . '" title="' . __('Log out of this account.', 'profilebuilder') . '">' . __('Logout', 'profilebuilder') . '  &raquo;</a></p><!-- .log-in-out .alert -->';
        $registerFilterArray['loginLogoutError'] = apply_filters('wppb_register_have_account_alert', $registerFilterArray['loginLogoutError'], $login->ID);
        echo $registerFilterArray['loginLogoutError'];
    } elseif ($new_user != 'no') {
        if (current_user_can('create_users')) {
            if ($multisite_message) {
                $registerFilterArray['wpmuRegistrationMessage1'] = '<p class="success">' . sprintf(__('An email has been sent to %1$s with information on how to activate his/her account.', 'profilebuilder'), $userdata['user_email']) . '</p><!-- .success -->';
                echo $registerFilterArray['registrationMessage1'] = apply_filters('wppb_wpmu_register_account_created1', $registerFilterArray['wpmuRegistrationMessage1'], $registered_name, $userdata['user_email']);
            } else {
                $registerFilterArray['registrationMessage1'] = '<p class="success">' . sprintf(__('A user account has been created for %1$s.', 'profilebuilder'), $registered_name) . '</p><!-- .success -->';
                echo $registerFilterArray['registrationMessage1'] = apply_filters('wppb_register_account_created1', $registerFilterArray['registrationMessage1'], $registered_name);
            }
            $redirectLink = wppb_curpageurl();
            if (file_exists(WPPB_PLUGIN_DIR . '/premium/addons/addon.php')) {
                //check to see if the redirecting addon is present and activated
                $wppb_addon_settings = get_option('wppb_addon_settings');
                if ($wppb_addon_settings['wppb_customRedirect'] == 'show') {
                    //check to see if the redirect location is not an empty string and is activated
                    $customRedirectSettings = get_option('customRedirectSettings');
                    if (trim($customRedirectSettings['afterRegisterTarget']) != '' && $customRedirectSettings['afterRegister'] == 'yes') {
                        $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
                        if (wppb_check_missing_http($redirectLink)) {
                            $redirectLink = 'http://' . $redirectLink;
                        }
                    }
                }
            }
            $registerFilterArray['redirectMessage1'] = '<font id="messageTextColor">' . sprintf(__('You will soon be redirected automatically. If you see this page for more than 3 seconds, please click %1$s.%2$s', 'profilebuilder'), '<a href="' . $redirectLink . '">' . __('here', 'profilebuilder') . '</a>', '<meta http-equiv="Refresh" content="3;url=' . $redirectLink . '" />') . '</font><br/><br/>';
            echo $registerFilterArray['redirectMessage1'] = apply_filters('wppb_register_redirect_after_creation1', $registerFilterArray['redirectMessage1'], $redirectLink);
        } else {
            if ($multisite_message) {
                $registerFilterArray['wpmuRegistrationMessage2'] = '<p class="success">' . __('An email has been sent to you with information on how to activate your account.', 'profilebuilder') . '</p><!-- .success -->';
                echo $registerFilterArray['wpmuRegistrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['wpmuRegistrationMessage2'], $registered_name);
            } else {
                $registerFilterArray['registrationMessage2'] = '<p class="success">' . sprintf(__('Thank you for registering %1$s.', 'profilebuilder'), $registered_name) . '</p><!-- .success -->';
                echo $registerFilterArray['registrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['registrationMessage2'], $registered_name);
            }
            $redirectLink = wppb_curpageurl();
            if (file_exists(WPPB_PLUGIN_DIR . '/premium/addons/addon.php')) {
                //check to see if the redirecting addon is present and activated
                $wppb_addon_settings = get_option('wppb_addon_settings');
                if ($wppb_addon_settings['wppb_customRedirect'] == 'show') {
                    //check to see if the redirect location is not an empty string and is activated
                    $customRedirectSettings = get_option('customRedirectSettings');
                    if (trim($customRedirectSettings['afterRegisterTarget']) != '' && $customRedirectSettings['afterRegister'] == 'yes') {
                        $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
                        if (wppb_check_missing_http($redirectLink)) {
                            $redirectLink = 'http://' . $redirectLink;
                        }
                    }
                }
            }
            $registerFilterArray['redirectMessage2'] = '<font id="messageTextColor">' . sprintf(__('You will soon be redirected automatically. If you see this page for more than 3 seconds, please click %1$s.%2$s', 'profilebuilder'), '<a href="' . $redirectLink . '">' . __('here', 'profilebuilder') . '</a>', '<meta http-equiv="Refresh" content="3;url=' . $redirectLink . '" />') . '</font><br/><br/>';
            echo $registerFilterArray['redirectMessage2'] = apply_filters('wppb_register_redirect_after_creation2', $registerFilterArray['redirectMessage2'], $redirectLink);
        }
        if (isset($_POST['send_credentials_via_email'])) {
            if ($sentEmailStatus == 1) {
                $registerFilterArray['emailMessage1'] = '<p class="error">' . __('An error occured while trying to send the notification email.', 'profilebuilder') . '</p><!-- .error -->';
                $registerFilterArray['emailMessage1'] = apply_filters('wppb_register_send_notification_email_fail', $registerFilterArray['emailMessage1']);
                echo $registerFilterArray['emailMessage1'];
            } elseif ($sentEmailStatus == 2) {
                if ($multisite_message) {
                    $registerFilterArray['wpmuEmailMessage2'] = '<p class="success">' . __('An email containing activation instructions was successfully sent.', 'profilebuilder') . '</p><!-- .success -->';
                    $registerFilterArray['wpmuEmailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['wpmuEmailMessage2']);
                    echo $registerFilterArray['wpmuEmailMessage2'];
                } else {
                    $registerFilterArray['emailMessage2'] = '<p class="success">' . __('An email containing the username and password was successfully sent.', 'profilebuilder') . '</p><!-- .success -->';
                    $registerFilterArray['emailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['emailMessage2']);
                    echo $registerFilterArray['emailMessage2'];
                }
            }
        }
    } else {
        if ($error) {
            $registerFilterArray['errorMessage'] = '<p class="error">' . $error . '</p><!-- .error -->';
            $registerFilterArray['errorMessage'] = apply_filters('wppb_register_error_messaging', $registerFilterArray['errorMessage'], $error);
            echo $registerFilterArray['errorMessage'];
        }
        if (current_user_can('create_users') && $registration) {
            $registerFilterArray['alertMessage1'] = '<p class="alert">' . __('Users can register themselves or you can manually create users here.', 'profilebuilder') . '</p><!-- .alert -->';
            $registerFilterArray['alertMessage1'] = apply_filters('wppb_register_alert_messaging1', $registerFilterArray['alertMessage1']);
            echo $registerFilterArray['alertMessage1'];
        } elseif (current_user_can('create_users')) {
            $registerFilterArray['alertMessage2'] = '<p class="alert">' . __('Users cannot currently register themselves, but you can manually create users here.', 'profilebuilder') . '</p><!-- .alert -->';
            $registerFilterArray['alertMessage2'] = apply_filters('wppb_register_alert_messaging2', $registerFilterArray['alertMessage2']);
            echo $registerFilterArray['alertMessage2'];
        } elseif (!current_user_can('create_users') && !$registration) {
            $registerFilterArray['alertMessage3'] = '<p class="alert">' . __('Only an administrator can add new users.', 'profilebuilder') . '</p><!-- .alert -->';
            $registerFilterArray['alertMessage3'] = apply_filters('wppb_register_alert_messaging3', $registerFilterArray['alertMessage3']);
            echo $registerFilterArray['alertMessage3'];
        }
        if ($registration || current_user_can('create_users')) {
            /* use this action hook to add extra content before the register form. */
            do_action('wppb_before_register_fields');
            ?>
					<form enctype="multipart/form-data" method="post" id="adduser" class="user-forms" action="http://<?php 
            echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            ?>
">
<?php 
            echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE . '" /><!-- set the MAX_FILE_SIZE to the server\'s current max upload size in bytes -->';
            $registerFilterArray2['name1'] = '<p class="registerNameHeading"><strong>' . __('Name', 'profilebuilder') . '</strong></p>';
            $registerFilterArray2['name1'] = apply_filters('wppb_register_content_name1', $registerFilterArray2['name1']);
            if ($wppb_defaultOptions['username'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['usernameRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
                    if (isset($_POST['user_name'])) {
                        if (trim($_POST['user_name']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
                    if ($wppb_defaultOptions['email'] == 'show') {
                        $errorVar = '';
                        $errorMark = '';
                        if ($wppb_defaultOptions['emailRequired'] == 'yes') {
                            $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                            if (isset($_POST['email'])) {
                                if (trim($_POST['email']) == '' || !is_email(trim($_POST['email']))) {
                                    $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
                                    $errorVar = ' errorHolder';
                                }
                            }
                        }
                        $localVar = '';
                        if (isset($_POST['email'])) {
                            $localVar = $_POST['email'];
                        }
                        $registerFilterArray2['name2'] = '
										<p class="form-email' . $errorVar . '">
											<label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label>
											<input class="text-input" name="email" type="text" id="email" value="' . trim($localVar) . '" />
										</p><!-- .form-email -->';
                        $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2_with_email', $registerFilterArray2['name2'], trim($localVar), $errorVar, $errorMark);
                    }
                } else {
                    $localVar = '';
                    if (isset($_POST['user_name'])) {
                        $localVar = $_POST['user_name'];
                    }
                    $registerFilterArray2['name2'] = '
									<p class="form-username' . $errorVar . '">
										<label for="user_name">' . __('Username', 'profilebuilder') . $errorMark . '</label>
										<input class="text-input" name="user_name" type="text" id="user_name" value="' . trim($localVar) . '" />
									</p><!-- .form-username -->';
                    $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2', $registerFilterArray2['name2'], trim($localVar), $errorVar, $errorMark);
                }
            }
            if ($wppb_defaultOptions['firstname'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['firstnameRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['first_name'])) {
                        if (trim($_POST['first_name']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['first_name'])) {
                    $localVar = $_POST['first_name'];
                }
                $registerFilterArray2['name3'] = '
								<p class="first_name' . $errorVar . '">
									<label for="first_name">' . __('First Name', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="first_name" type="text" id="first_name" value="' . trim($localVar) . '" />
								</p><!-- .first_name -->';
                $registerFilterArray2['name3'] = apply_filters('wppb_register_content_name3', $registerFilterArray2['name3'], trim($localVar), $errorVar, $errorMark);
            }
            if ($wppb_defaultOptions['lastname'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['lastnameRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['last_name'])) {
                        if (trim($_POST['last_name']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['last_name'])) {
                    $localVar = $_POST['last_name'];
                }
                $registerFilterArray2['name4'] = '
								<p class="last_name' . $errorVar . '">
									<label for="last_name">' . __('Last Name', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="last_name" type="text" id="last_name" value="' . trim($localVar) . '" />
								</p><!-- .last_name -->';
                $registerFilterArray2['name4'] = apply_filters('wppb_register_content_name4', $registerFilterArray2['name4'], trim($localVar), $errorVar, $errorMark);
            }
            if ($wppb_defaultOptions['nickname'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['nicknameRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['nickname'])) {
                        if (trim($_POST['nickname']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['nickname'])) {
                    $localVar = $_POST['nickname'];
                }
                $registerFilterArray2['name5'] = '
								<p class="nickname' . $errorVar . '">
									<label for="nickname">' . __('Nickname', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="nickname" type="text" id="nickname" value="' . trim($localVar) . '" />
								</p><!-- .nickname -->';
                $registerFilterArray2['name5'] = apply_filters('wppb_register_content_name5', $registerFilterArray2['name5'], trim($localVar), $errorVar, $errorMark);
            }
            $registerFilterArray2['info1'] = '<p class="registerContactInfoHeading"><strong>' . __('Contact Info', 'profilebuilder') . '</strong></p>';
            $registerFilterArray2['info1'] = apply_filters('wppb_register_content_info1', $registerFilterArray2['info1']);
            if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            } else {
                if ($wppb_defaultOptions['email'] == 'show') {
                    $errorVar = '';
                    $errorMark = '';
                    if ($wppb_defaultOptions['emailRequired'] == 'yes') {
                        $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                        if (isset($_POST['email'])) {
                            if (trim($_POST['email']) == '' || !is_email(trim($_POST['email']))) {
                                $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
                                $errorVar = ' errorHolder';
                            }
                        }
                    }
                    $localVar = '';
                    if (isset($_POST['email'])) {
                        $localVar = $_POST['email'];
                    }
                    $registerFilterArray2['info2'] = '
									<p class="form-email' . $errorVar . '">
										<label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label>
										<input class="text-input" name="email" type="text" id="email" value="' . trim($localVar) . '" />
									</p><!-- .form-email -->';
                    $registerFilterArray2['info2'] = apply_filters('wppb_register_content_info2', $registerFilterArray2['info2'], trim($localVar), $errorVar, $errorMark);
                }
            }
            if ($wppb_defaultOptions['website'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['websiteRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['website'])) {
                        if (trim($_POST['website']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['website'])) {
                    $localVar = $_POST['website'];
                }
                $registerFilterArray2['info3'] = '
								<p class="form-website' . $errorVar . '">
									<label for="website">' . __('Website', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="website" type="text" id="website" value="' . trim($localVar) . '" />
								</p><!-- .form-website -->';
                $registerFilterArray2['info3'] = apply_filters('wppb_register_content_info3', $registerFilterArray2['info3'], trim($localVar), $errorVar, $errorMark);
            }
            if ($wppb_defaultOptions['aim'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['aimRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['aim'])) {
                        if (trim($_POST['aim']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['aim'])) {
                    $localVar = $_POST['aim'];
                }
                $registerFilterArray2['info4'] = '
								<p class="form-aim' . $errorVar . '">
									<label for="aim">' . __('AIM', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="aim" type="text" id="aim" value="' . trim($localVar) . '" />
								</p><!-- .form-aim -->';
                $registerFilterArray2['info4'] = apply_filters('wppb_register_content_info4', $registerFilterArray2['info4'], trim($localVar), $errorVar, $errorMark);
            }
            if ($wppb_defaultOptions['yahoo'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['yahooRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['yim'])) {
                        if (trim($_POST['yim']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['yim'])) {
                    $localVar = $_POST['yim'];
                }
                $registerFilterArray2['info5'] = '
								<p class="form-yim' . $errorVar . '">
									<label for="yim">' . __('Yahoo IM', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="yim" type="text" id="yim" value="' . trim($localVar) . '" />
								</p><!-- .form-yim -->';
                $registerFilterArray2['info5'] = apply_filters('wppb_register_content_info5', $registerFilterArray2['info5'], trim($localVar), $errorVar, $errorMark);
            }
            if ($wppb_defaultOptions['jabber'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['jabberRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['jabber'])) {
                        if (trim($_POST['jabber']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['jabber'])) {
                    $localVar = $_POST['jabber'];
                }
                $registerFilterArray2['info6'] = '
								<p class="form-jabber' . $errorVar . '">
									<label for="jabber">' . __('Jabber / Google Talk', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="jabber" type="text" id="jabber" value="' . trim($localVar) . '" />
								</p><!-- .form-jabber -->';
                $registerFilterArray2['info6'] = apply_filters('wppb_register_content_info6', $registerFilterArray2['info6'], trim($localVar), $errorVar, $errorMark);
            }
            $registerFilterArray2['ay1'] = '<p class="registerAboutYourselfHeader"><strong>' . __('About Yourself', 'profilebuilder') . '</strong></p>';
            $registerFilterArray2['ay1'] = apply_filters('wppb_register_content_about_yourself1', $registerFilterArray2['ay1']);
            if ($wppb_defaultOptions['bio'] == 'show') {
                $errorVar = '';
                $errorMark = '';
                if ($wppb_defaultOptions['bioRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>';
                    if (isset($_POST['description'])) {
                        if (trim($_POST['description']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                }
                $localVar = '';
                if (isset($_POST['description'])) {
                    $localVar = $_POST['description'];
                }
                $registerFilterArray2['ay2'] = '
								<p class="form-description' . $errorVar . '">
									<label for="description">' . __('Biographical Info', 'profilebuilder') . $errorMark . '</label>
									<textarea class="text-input" name="description" id="description" rows="5" cols="30">' . trim($localVar) . '</textarea>
								</p><!-- .form-description -->';
                $registerFilterArray2['ay2'] = apply_filters('wppb_register_content_about_yourself2', $registerFilterArray2['ay2'], trim($localVar), $errorVar, $errorMark);
            }
            if ($wppb_defaultOptions['password'] == 'show') {
                $errorMark = '';
                $errorMark2 = '';
                $errorVar = '';
                $errorVar2 = '';
                if ($wppb_defaultOptions['passwordRequired'] == 'yes') {
                    $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
                    $errorMark2 = '<font color="red" title="This field is required for registration.">*</font>';
                    if (isset($_POST['passw1'])) {
                        if (trim($_POST['passw1']) == '') {
                            $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
                            $errorVar = ' errorHolder';
                        }
                    }
                    if (isset($_POST['passw2'])) {
                        if (trim($_POST['passw2']) == '') {
                            $errorMark2 = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
                            $errorVar2 = ' errorHolder';
                        }
                    }
                }
                $localVar1 = '';
                if (isset($_POST['passw1'])) {
                    $localVar1 = $_POST['passw1'];
                }
                $localVar2 = '';
                if (isset($_POST['passw2'])) {
                    $localVar2 = $_POST['passw2'];
                }
                $registerFilterArray2['ay3'] = '
								<p class="form-password' . $errorVar . '">
									<label for="pass1">' . __('Password', 'profilebuilder') . $errorMark . '</label>
									<input class="text-input" name="passw1" type="password" id="pass1" value="' . trim($localVar1) . '" />
								</p><!-- .form-password -->
				 
								<p class="form-password' . $errorVar2 . '">
									<label for="pass2">' . __('Repeat Password', 'profilebuilder') . $errorMark2 . '</label>
									<input class="text-input" name="passw2" type="password" id="pass2" value="' . trim($localVar2) . '" />
								</p><!-- .form-password -->';
                $registerFilterArray2['ay3'] = apply_filters('wppb_register_content_about_yourself3', $registerFilterArray2['ay3'], trim($localVar1), trim($localVar2), $errorVar, $errorMark, $errorVar2, $errorMark2);
            }
            $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
            if (file_exists($wppb_premium . 'extra.fields.php')) {
                require_once $wppb_premium . 'extra.fields.php';
                //register_user_extra_fields($error, $_POST, $extraFieldsErrorHolder);
                $page = 'register';
                $returnedValue = wppb_extra_fields($current_user->id, $extraFieldsErrorHolder, $registerFilterArray, $page, $error, $_POST);
                //copy over extra fields to the rest of the fieldso on the edit profile
                foreach ($returnedValue as $key => $value) {
                    $registerFilterArray2[$key] = apply_filters('wppb_register_content_' . $key, $value);
                }
            }
            if (function_exists('wppb_add_recaptcha_to_registration_form')) {
                $wppb_addon_settings = get_option('wppb_addon_settings');
                if ($wppb_addon_settings['wppb_reCaptcha'] == 'show') {
                    $reCAPTCHAForm = wppb_add_recaptcha_to_registration_form();
                    $labelName = apply_filters('wppb_register_anti_spam_title', __('Anti-Spam', 'profilebuilder'));
                    $registerFilterArray2['reCAPTCHAForm'] = '<div class="form-reCAPTCHA"><label class="form-reCAPTCHA-label" for="' . $labelName . '">' . $labelName . '</label>' . $reCAPTCHAForm . '</div><!-- .form-reCAPTCHA -->';
                }
            }
            // additional filter, just in case it is needed
            $registerFilterArray2['extraRegistrationFilter'] = '';
            $registerFilterArray2['extraRegistrationFilter'] = apply_filters('extraRegistrationField', $registerFilterArray2['extraRegistrationFilter']);
            // END additional filter, just in case it is needed
            $wppb_generalSettings = get_option('wppb_general_settings');
            if ($wppb_generalSettings['emailConfirmation'] != 'yes') {
                if (!is_multisite()) {
                    if (isset($_POST['send_credentials_via_email'])) {
                        $checkedVar = ' checked';
                    } else {
                        $checkedVar = '';
                    }
                    $registerFilterArray2['confirmationEmailForm'] = '
										<p class="send-confirmation-email">
											<label for="send-confirmation-email"> 
												<input id="send_credentials_via_email" type="checkbox" name="send_credentials_via_email" value="sending"' . $checkedVar . '/>
												' . __('Send these credentials via email.', 'profilebuilder') . '
											</label>
										</p><!-- .send-confirmation-email -->';
                    $registerFilterArray2['confirmationEmailForm'] = apply_filters('wppb_register_confirmation_email_form', $registerFilterArray2['confirmationEmailForm'], $checkedVar);
                }
            }
            $registerFilterArray2 = apply_filters('wppb_register', $registerFilterArray2);
            foreach ($registerFilterArray2 as $key => $value) {
                echo $value;
            }
            ?>
							
						<p class="form-submit">
							<input name="adduser" type="submit" id="addusersub" class="submit button" value="<?php 
            if (current_user_can('create_users')) {
                _e('Add User', 'profilebuilder');
            } else {
                _e('Register', 'profilebuilder');
            }
            ?>
" />
							<input name="action" type="hidden" id="action" value="adduser" />
							<input type="hidden" name="formName" value="register" />
						</p><!-- .form-submit -->
<?php 
            wp_nonce_field('verify_true_registration', 'register_nonce_field');
            ?>
					</form><!-- #adduser -->

<?php 
        }
    }
    /* use this action hook to add extra content after the register form. */
    do_action('wppb_after_register_fields');
    ?>
	
	</div>
<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #19
0
 /**
  * Add the custom sizes to the image sizes in article edition
  * 
  * @access public
  * @param array $form_fields
  * @param object $post
  * @return void
  * @author Nicolas Juen
  * @author Additional Image Sizes (zui)
  */
 public function sizesInForm($form_fields, $post)
 {
     // Protect from being view in Media editor where there are no sizes
     if (isset($form_fields['image-size'])) {
         $out = NULL;
         $size_names = array();
         $sizes_custom = get_option(SIS_OPTION);
         if (is_array($sizes_custom)) {
             foreach ($sizes_custom as $key => $value) {
                 if (isset($value['s']) && $value['s'] == 1) {
                     $size_names[$key] = $this->_getThumbnailName($key);
                 }
             }
         }
         foreach ($size_names as $size => $label) {
             $downsize = image_downsize($post->ID, $size);
             // is this size selectable?
             $enabled = $downsize[3] || 'full' == $size;
             $css_id = "image-size-{$size}-{$post->ID}";
             // We must do a clumsy search of the existing html to determine is something has been checked yet
             if (FALSE === strpos('checked="checked"', $form_fields['image-size']['html'])) {
                 if (empty($check)) {
                     $check = get_user_setting('imgsize');
                 }
                 // See if they checked a custom size last time
                 $checked = '';
                 // if this size is the default but that's not available, don't select it
                 if ($size == $check || str_replace(" ", "", $size) == $check) {
                     if ($enabled) {
                         $checked = " checked='checked'";
                     } else {
                         $check = '';
                     }
                 } elseif (!$check && $enabled && 'thumbnail' != $size) {
                     // if $check is not enabled, default to the first available size that's bigger than a thumbnail
                     $check = $size;
                     $checked = " checked='checked'";
                 }
             }
             $html = "<div class='image-size-item' style='min-height: 50px; margin-top: 18px;'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
             $html .= "<label for='{$css_id}'>{$label}</label>";
             // only show the dimensions if that choice is available
             if ($enabled) {
                 $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
             }
             $html .= '</div>';
             $out .= $html;
         }
         $form_fields['image-size']['html'] .= $out;
     }
     // End protect from Media editor
     return $form_fields;
 }
Example #20
0
function parseTemplate($id, $type, $template, $orig_filename, $icon = "")
{
    DebugEcho("parseTemplate - before: {$template}");
    $size = 'medium';
    /* we check template for thumb, thumbnail, large, full and use that as
       size. If not found, we default to medium */
    if ($type == 'image') {
        $sizes = array('thumbnail', 'medium', 'large');
        $hwstrings = array();
        $widths = array();
        $heights = array();
        for ($i = 0; $i < count($sizes); $i++) {
            list($img_src[$i], $widths[$i], $heights[$i]) = image_downsize($id, $sizes[$i]);
            $hwstrings[$i] = image_hwstring($widths[$i], $heights[$i]);
        }
    }
    $attachment = get_post($id);
    $the_parent = get_post($attachment->post_parent);
    $uploadDir = wp_upload_dir();
    $fileName = basename($attachment->guid);
    $absFileName = $uploadDir['path'] . '/' . $fileName;
    $relFileName = str_replace(ABSPATH, '', $absFileName);
    $fileLink = wp_get_attachment_url($id);
    $pageLink = get_attachment_link($id);
    $template = str_replace('{TITLE}', $attachment->post_title, $template);
    $template = str_replace('{ID}', $id, $template);
    if ($type == 'image') {
        $template = str_replace('{THUMBNAIL}', $img_src[0], $template);
        $template = str_replace('{THUMB}', $img_src[0], $template);
        $template = str_replace('{MEDIUM}', $img_src[1], $template);
        $template = str_replace('{LARGE}', $img_src[2], $template);
        $template = str_replace('{THUMBWIDTH}', $widths[0] . 'px', $template);
        $template = str_replace('{THUMBHEIGHT}', $heights[0] . 'px', $template);
        $template = str_replace('{MEDIUMWIDTH}', $widths[1] . 'px', $template);
        $template = str_replace('{MEDIUMHEIGHT}', $heights[1] . 'px', $template);
        $template = str_replace('{LARGEWIDTH}', $widths[2] . 'px', $template);
        $template = str_replace('{LARGEHEIGHT}', $heights[2] . 'px', $template);
    }
    $template = str_replace('{FULL}', $fileLink, $template);
    $template = str_replace('{FILELINK}', $fileLink, $template);
    $template = str_replace('{PAGELINK}', $pageLink, $template);
    $template = str_replace('{FILENAME}', $orig_filename, $template);
    $template = str_replace('{IMAGE}', $fileLink, $template);
    $template = str_replace('{URL}', $fileLink, $template);
    $template = str_replace('{RELFILENAME}', $relFileName, $template);
    $template = str_replace('{POSTTITLE}', $the_parent->post_title, $template);
    $template = str_replace('{ICON}', $icon, $template);
    DebugEcho("parseTemplate - after: {$template}");
    return $template . '<br />';
}
Example #21
0
/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since 2.7.0
 *
 * @param object $post
 * @param bool|string $check
 * @return array
 */
function image_size_input_fields($post, $check = '')
{
    /**
     * Filter the names and labels of the default image sizes.
     *
     * @since 3.3.0
     *
     * @param array $size_names Array of image sizes and their names. Default values
     *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     */
    $size_names = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')));
    if (empty($check)) {
        $check = get_user_setting('imgsize', 'medium');
    }
    foreach ($size_names as $size => $label) {
        $downsize = image_downsize($post->ID, $size);
        $checked = '';
        // Is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // If this size is the default but that's not available, don't select it.
        if ($size == $check) {
            if ($enabled) {
                $checked = " checked='checked'";
            } else {
                $check = '';
            }
        } elseif (!$check && $enabled && 'thumbnail' != $size) {
            /*
             * If $check is not enabled, default to the first available size
             * that's bigger than a thumbnail.
             */
            $check = $size;
            $checked = " checked='checked'";
        }
        $html = "<div class='image-size-item'><input type='radio' " . disabled($enabled, false, false) . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'{$checked} />";
        $html .= "<label for='{$css_id}'>{$label}</label>";
        // Only show the dimensions if that choice is available.
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf("(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}
Example #22
0
/**
 * Retrieve URL for an attachment thumbnail.
 *
 * @since 2.1.0
 *
 * @param int $post_id Optional. Attachment ID. Default 0.
 * @return string|false False on failure. Thumbnail URL on success.
 */
function wp_get_attachment_thumb_url($post_id = 0)
{
    $post_id = (int) $post_id;
    if (!($post = get_post($post_id))) {
        return false;
    }
    if (!($url = wp_get_attachment_url($post->ID))) {
        return false;
    }
    $sized = image_downsize($post_id, 'thumbnail');
    if ($sized) {
        return $sized[0];
    }
    if (!($thumb = wp_get_attachment_thumb_file($post->ID))) {
        return false;
    }
    $url = str_replace(basename($url), basename($thumb), $url);
    /**
     * Filter the attachment thumbnail URL.
     *
     * @since 2.1.0
     *
     * @param string $url     URL for the attachment thumbnail.
     * @param int    $post_id Attachment ID.
     */
    return apply_filters('wp_get_attachment_thumb_url', $url, $post->ID);
}
Example #23
0
/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since unknown
 *
 * @param unknown_type $post
 * @param unknown_type $checked
 * @return unknown
 */
function image_size_input_fields($post, $checked = '')
{
    // get a list of the actual pixel dimensions of each possible intermediate version of this image
    $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size'));
    foreach ($size_names as $size => $name) {
        $downsize = image_downsize($post->ID, $size);
        // is this size selectable?
        $enabled = $downsize[3] || 'full' == $size;
        $css_id = "image-size-{$size}-{$post->ID}";
        // if this size is the default but that's not available, don't select it
        if ($checked && !$enabled) {
            $checked = '';
        }
        // if $checked was not specified, default to the first available size that's bigger than a thumbnail
        if (!$checked && $enabled && 'thumbnail' != $size) {
            $checked = $size;
        }
        $html = "<div class='image-size-item'><input type='radio' " . ($enabled ? '' : "disabled='disabled'") . "name='attachments[{$post->ID}][image-size]' id='{$css_id}' value='{$size}'" . ($checked == $size ? " checked='checked'" : '') . " />";
        $html .= "<label for='{$css_id}'>" . __($name) . "</label>";
        // only show the dimensions if that choice is available
        if ($enabled) {
            $html .= " <label for='{$css_id}' class='help'>" . sprintf(__("(%d&nbsp;&times;&nbsp;%d)"), $downsize[1], $downsize[2]) . "</label>";
        }
        $html .= '</div>';
        $out[] = $html;
    }
    return array('label' => __('Size'), 'input' => 'html', 'html' => join("\n", $out));
}
Example #24
0
/**
 * Retrieve HTML for the size radio buttons with the specified one checked.
 *
 * @since unknown
 *
 * @param unknown_type $post
 * @param unknown_type $checked
 * @return unknown
 */
function image_size_input_fields( $post, $check = '' ) {

		// get a list of the actual pixel dimensions of each possible intermediate version of this image
		$size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'));

		if ( empty($check) )
			$check = get_user_setting('imgsize', 'medium');

		foreach ( $size_names as $size => $label ) {
			$downsize = image_downsize($post->ID, $size);
			$checked = '';

			// is this size selectable?
			$enabled = ( $downsize[3] || 'full' == $size );
			$css_id = "image-size-{$size}-{$post->ID}";
			// if this size is the default but that's not available, don't select it
			if ( $size == $check ) {
				if ( $enabled )
					$checked = " checked='checked'";
				else
					$check = '';
			} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
				// if $check is not enabled, default to the first available size that's bigger than a thumbnail
				$check = $size;
				$checked = " checked='checked'";
			}

			$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";

			$html .= "<label for='{$css_id}'>$label</label>";
			// only show the dimensions if that choice is available
			if ( $enabled )
				$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";

			$html .= '</div>';

			$out[] = $html;
		}

		return array(
			'label' => __('Size'),
			'input' => 'html',
			'html'  => join("\n", $out),
		);
}
 /**
  * Prepares media item data for return in an XML-RPC object.
  *
  * @access protected
  *
  * @param object $media_item The unprepared media item data
  * @param string $thumbnail_size The image size to use for the thumbnail URL
  * @return array The prepared media item data
  */
 protected function _prepare_media_item($media_item, $thumbnail_size = 'thumbnail')
 {
     $_media_item = array('attachment_id' => strval($media_item->ID), 'date_created_gmt' => $this->_convert_date_gmt($media_item->post_date_gmt, $media_item->post_date), 'parent' => $media_item->post_parent, 'link' => wp_get_attachment_url($media_item->ID), 'title' => $media_item->post_title, 'caption' => $media_item->post_excerpt, 'description' => $media_item->post_content, 'metadata' => wp_get_attachment_metadata($media_item->ID));
     $thumbnail_src = image_downsize($media_item->ID, $thumbnail_size);
     if ($thumbnail_src) {
         $_media_item['thumbnail'] = $thumbnail_src[0];
     } else {
         $_media_item['thumbnail'] = $_media_item['link'];
     }
     return apply_filters('xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size);
 }
Example #26
0
 public function image($image = '')
 {
     global $post;
     // Grab the featured image
     if (is_singular()) {
         if (empty($image) && function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
             $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-thumbnail');
             if ($thumbnail) {
                 $image = $thumbnail[0];
             }
             // If that's not there, grab the first attached image
         } else {
             $files = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
             if ($files) {
                 $keys = array_reverse(array_keys($files));
                 $image = image_downsize($keys[0], 'thumbnail');
                 $image = $image[0];
             }
         }
     }
     if ($image != '') {
         echo "<meta property='og:image' content='" . esc_attr($image) . "'/>\n";
     }
 }
Example #27
0
/**
 * Retrieve an image to represent an attachment.
 *
 * A mime icon for files, thumbnail or intermediate size for images.
 *
 * The returned array contains four values: the URL of the attachment image src,
 * the width of the image file, the height of the image file, and a boolean
 * representing whether the returned array describes an intermediate (generated)
 * image size or the original, full-sized upload.
 *
 * @since 2.5.0
 *
 * @param int          $attachment_id Image attachment ID.
 * @param string|array $size          Optional. Image size. Accepts any valid image size, or an array of width
 *                                    and height values in pixels (in that order). Default 'thumbnail'.
 * @param bool         $icon          Optional. Whether the image should be treated as an icon. Default false.
 * @return false|array Returns an array (url, width, height, is_intermediate), or false, if no image is available.
 */
function wp_get_attachment_image_src($attachment_id, $size = 'thumbnail', $icon = false)
{
    // get a thumbnail or intermediate image if there is one
    $image = image_downsize($attachment_id, $size);
    if (!$image) {
        $src = false;
        if ($icon && ($src = wp_mime_type_icon($attachment_id))) {
            /** This filter is documented in wp-includes/post.php */
            $icon_dir = apply_filters('icon_dir', ABSPATH . WPINC . '/images/media');
            $src_file = $icon_dir . '/' . wp_basename($src);
            @(list($width, $height) = getimagesize($src_file));
        }
        if ($src && $width && $height) {
            $image = array($src, $width, $height);
        }
    }
    /**
     * Filter the image src result.
     *
     * @since 4.3.0
     *
     * @param array|false  $image         Either array with src, width & height, icon src, or false.
     * @param int          $attachment_id Image attachment ID.
     * @param string|array $size          Size of image. Image size or array of width and height values
     *                                    (in that order). Default 'thumbnail'.
     * @param bool         $icon          Whether the image should be treated as an icon. Default false.
     */
    return apply_filters('wp_get_attachment_image_src', $image, $attachment_id, $size, $icon);
}
 /**
  * Prepares media item data for return in an XML-RPC object.
  *
  * @access protected
  *
  * @param object $media_item The unprepared media item data
  * @param string $thumbnail_size The image size to use for the thumbnail URL
  * @return array The prepared media item data
  */
 protected function _prepare_media_item($media_item, $thumbnail_size = 'thumbnail')
 {
     $_media_item = array('attachment_id' => strval($media_item->ID), 'date_created_gmt' => $this->_convert_date_gmt($media_item->post_date_gmt, $media_item->post_date), 'parent' => $media_item->post_parent, 'link' => wp_get_attachment_url($media_item->ID), 'title' => $media_item->post_title, 'caption' => $media_item->post_excerpt, 'description' => $media_item->post_content, 'metadata' => wp_get_attachment_metadata($media_item->ID));
     $thumbnail_src = image_downsize($media_item->ID, $thumbnail_size);
     if ($thumbnail_src) {
         $_media_item['thumbnail'] = $thumbnail_src[0];
     } else {
         $_media_item['thumbnail'] = $_media_item['link'];
     }
     /**
      * Filter XML-RPC-prepared data for the given media item.
      *
      * @since 3.4.0
      *
      * @param array  $_media_item    An array of media item data.
      * @param object $media_item     Media item object.
      * @param string $thumbnail_size Image size.
      */
     return apply_filters('xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size);
 }
Example #29
0
/**
 * Retrieve URL for an attachment thumbnail.
 *
 * @since 2.1.0
 *
 * @param int $post_id Attachment ID
 * @return string|bool False on failure. Thumbnail URL on success.
 */
function wp_get_attachment_thumb_url($post_id = 0)
{
    $post_id = (int) $post_id;
    if (!($post =& get_post($post_id))) {
        return false;
    }
    if (!($url = wp_get_attachment_url($post->ID))) {
        return false;
    }
    $sized = image_downsize($post_id, 'thumbnail');
    if ($sized) {
        return $sized[0];
    }
    if (!($thumb = wp_get_attachment_thumb_file($post->ID))) {
        return false;
    }
    $url = str_replace(basename($url), basename($thumb), $url);
    return apply_filters('wp_get_attachment_thumb_url', $url, $post->ID);
}
Example #30
0
        public function get_attachment_image_src($pid, $size_name = 'thumbnail', $check_dupes = true)
        {
            $this->p->debug->args(array('pid' => $pid, 'size_name' => $size_name, 'check_dupes' => $check_dupes));
            $size_info = $this->get_size_info($size_name);
            $img_url = '';
            $img_width = -1;
            $img_height = -1;
            $img_cropped = empty($size_info['crop']) ? 0 : 1;
            $ret_empty = array(null, null, null, null);
            if ($this->p->is_avail['media']['ngg'] === true && strpos($pid, 'ngg-') === 0) {
                if (!empty($this->p->addons['media']['ngg'])) {
                    return $this->p->addons['media']['ngg']->get_image_src($pid, $size_name, $check_dupes);
                } else {
                    if (is_admin()) {
                        $this->p->notice->err('The NextGEN Gallery addon is not available: image id ' . $pid . ' ignored.');
                    } else {
                        $this->p->debug->log('ngg addon is not available: image id ' . $attr_value . ' ignored');
                    }
                    return $ret_empty;
                }
            } elseif (!wp_attachment_is_image($pid)) {
                $this->p->debug->log('exiting early: attachment ' . $pid . ' is not an image');
                return $ret_empty;
            }
            if (strpos($size_name, $this->p->cf['lca'] . '-') !== false) {
                // only resize our own custom image sizes
                if (!empty($this->p->options['plugin_auto_img_resize'])) {
                    // 'Auto-Resize Images' option must be enabled
                    $img_meta = wp_get_attachment_metadata($pid);
                    if (empty($img_meta['sizes'][$size_name])) {
                        // does the image metadata contain our image sizes?
                        $is_accurate_width = false;
                        $is_accurate_height = false;
                    } else {
                        // is the width and height in the image metadata accurate?
                        $is_accurate_width = !empty($img_meta['sizes'][$size_name]['width']) && $img_meta['sizes'][$size_name]['width'] == $size_info['width'] ? true : false;
                        $is_accurate_height = !empty($img_meta['sizes'][$size_name]['height']) && $img_meta['sizes'][$size_name]['height'] == $size_info['height'] ? true : false;
                        // if not cropped, make sure the resized image respects the original aspect ratio
                        if ($is_accurate_width && $is_accurate_height && empty($size_info['crop'])) {
                            if ($img_meta['width'] > $img_meta['height']) {
                                $ratio = $img_meta['width'] / $size_info['width'];
                                $check = 'height';
                            } else {
                                $ratio = $img_meta['height'] / $size_info['height'];
                                $check = 'width';
                            }
                            $should_be = (int) round($img_meta[$check] / $ratio);
                            // allow for a +/-1 pixel difference
                            if ($img_meta['sizes'][$size_name][$check] < $should_be - 1 || $img_meta['sizes'][$size_name][$check] > $should_be + 1) {
                                $is_accurate_width = false;
                                $is_accurate_height = false;
                            }
                        }
                    }
                    // depending on cropping, one or both sides of the image must be accurate
                    // if not, attempt to create a resized image by calling image_make_intermediate_size()
                    if (empty($size_info['crop']) && (!$is_accurate_width && !$is_accurate_height) || !empty($size_info['crop']) && (!$is_accurate_width || !$is_accurate_height)) {
                        if ($this->p->debug->is_on()) {
                            if (empty($img_meta['sizes'][$size_name])) {
                                $this->p->debug->log($size_name . ' size not defined in the image meta');
                            } else {
                                $this->p->debug->log('image metadata (' . (empty($img_meta['sizes'][$size_name]['width']) ? 0 : $img_meta['sizes'][$size_name]['width']) . 'x' . (empty($img_meta['sizes'][$size_name]['height']) ? 0 : $img_meta['sizes'][$size_name]['height']) . ') does not match ' . $size_name . ' (' . $size_info['width'] . 'x' . $size_info['height'] . (empty($size_info['crop']) ? '' : ' cropped') . ')');
                            }
                        }
                        $fullsizepath = get_attached_file($pid);
                        $resized = image_make_intermediate_size($fullsizepath, $size_info['width'], $size_info['height'], $size_info['crop']);
                        $this->p->debug->log('image_make_intermediate_size() reported ' . ($resized === false ? 'failure' : 'success'));
                        if ($resized !== false) {
                            $img_meta['sizes'][$size_name] = $resized;
                            wp_update_attachment_metadata($pid, $img_meta);
                        }
                    }
                } else {
                    $this->p->debug->log('image metadata check skipped: plugin_auto_img_resize option is disabled');
                }
            }
            list($img_url, $img_width, $img_height) = apply_filters($this->p->cf['lca'] . '_image_downsize', image_downsize($pid, $size_name), $pid, $size_name);
            $this->p->debug->log('image_downsize() = ' . $img_url . ' (' . $img_width . 'x' . $img_height . ')');
            if (empty($img_url)) {
                $this->p->debug->log('exiting early: returned image_downsize() url is empty');
                return $ret_empty;
            }
            // check for resulting image dimenions that may be too small
            if (!empty($this->p->options['plugin_ignore_small_img'])) {
                $is_sufficient_width = $img_width >= $size_info['width'] ? true : false;
                $is_sufficient_height = $img_height >= $size_info['height'] ? true : false;
                // depending on cropping, one or both sides of the image must be large enough / sufficient
                // return an empty array after showing an appropriate warning
                if (empty($size_info['crop']) && (!$is_sufficient_width && !$is_sufficient_height) || !empty($size_info['crop']) && (!$is_sufficient_width || !$is_sufficient_height)) {
                    $size_too_small_text = ' too small for ' . $size_name . ' dimensions (' . $size_info['width'] . 'x' . $size_info['height'] . (empty($size_info['crop']) ? '' : ' cropped') . ')';
                    $img_meta = wp_get_attachment_metadata($pid);
                    if (!empty($img_meta['width']) && !empty($img_meta['height']) && $img_meta['width'] < $size_info['width'] && $img_meta['height'] < $size_info['height']) {
                        $rejected_text = 'image id ' . $pid . ' rejected - original image ' . $img_meta['width'] . 'x' . $img_meta['height'] . $size_too_small_text;
                    } else {
                        $rejected_text = 'image id ' . $pid . ' rejected - ' . $img_width . 'x' . $img_height . $size_too_small_text;
                    }
                    $this->p->debug->log('exiting early: ' . $rejected_text);
                    if (is_admin()) {
                        $this->p->notice->err('Media Library ' . $rejected_text . '.
							Upload a larger image, or adjust the ' . $size_name . ' image dimensions setting.', false, true, 'dim_wp_' . $pid);
                    }
                    return $ret_empty;
                } else {
                    $this->p->debug->log('returned image dimensions (' . $img_width . 'x' . $img_height . ') are sufficient');
                }
            }
            if ($check_dupes == false || $this->p->util->is_uniq_url($img_url)) {
                return array(apply_filters($this->p->cf['lca'] . '_rewrite_url', $img_url), $img_width, $img_height, $img_cropped);
            }
            return $ret_empty;
        }