/** * Get Screenshot URL for Call to Action preview. If local environment show template thumbnail. * * @param INT $cta_id id if of call to action * @param INT $vid id of variation belonging to call to action * * @return STRING url of preview */ public static function get_screenshot_url($cta_id, $vid = null) { if ($vid === null) { $vid = CTA_Variations::get_current_variation_id(); } $template = CTA_Variations::get_current_template($cta_id, $vid); if (in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { if (file_exists(WP_CTA_UPLOADS_URLPATH . 'templates/' . $template . '/thumbnail.png')) { $screenshot = WP_CTA_UPLOADS_URLPATH . 'templates/' . $template . '/thumbnail.png'; } else { $screenshot = WP_CTA_URLPATH . 'templates/' . $template . '/thumbnail.png'; } } else { $screenshot = 'http://s.wordpress.com/mshots/v1/' . urlencode(esc_url($permalink)) . '?w=140'; } return $screenshot; }