public function ajax_upload_image() { require_once dirname(__FILE__) . '/polldaddy-client.php'; check_admin_referer('send-media'); $attach_id = $media_id = $user_code = 0; $name = $url = ''; if (isset($_POST['attach-id'])) { $attach_id = (int) $_POST['attach-id']; } if (isset($_POST['media-id'])) { $media_id = (int) $_POST['media-id']; } if (isset($_POST['uc'])) { $user_code = $_POST['uc']; } if (isset($_POST['url'])) { $url = $_POST['url']; } $parts = pathinfo($url); $name = preg_replace('/\\?.*/', '', $parts['basename']); $polldaddy = new api_client(WP_POLLDADDY__PARTNERGUID, $user_code); $data = ''; if (function_exists('is_private_blog') && is_private_blog()) { $file_path = get_attached_file($attach_id); $data = base64_encode(@file_get_contents($file_path)); } $response = $polldaddy->upload_image($name, $url, 'poll', $media_id > 1000 ? $media_id : 0, $data); if (is_a($response, "PollDaddy_Media")) { echo urldecode($response->upload_result) . '||' . $media_id; } die; }
/** * Generates the HTML for the edit attachment field. * * @param $attachment object The attachment currently being edited. * @return string The HTML for the form field. */ public function get_attachment_field_html($attachment) { $sizes = $this->use_ratio_map ? $this->get_image_sizes_by_ratio() : $this->get_intermediate_image_sizes(); $sizes = apply_filters('wpcom_thumbnail_editor_image_size_names_choose', $sizes); if (empty($sizes)) { return '<p>' . __('No thumbnail sizes could be found that are cropped. For now this functionality only supports cropped thumbnails.', 'wpcom-thumbnail-editor') . '</p>'; } // Photon has to be able to access the source images if (function_exists('is_private_blog') && is_private_blog()) { return '<p>' . sprintf(__("The WordPress.com VIP custom thumbnail cropping functionality doesn't work on sites <a href='%s'>marked as private</a>.", 'wpcom-thumbnail-editor'), admin_url('options-reading.php')) . '</p>'; } elseif ('localhost' == $_SERVER['HTTP_HOST']) { return '<p>' . __("The WordPress.com VIP custom thumbnail cropping functionality needs the images be publicly accessible in order to work, which isn't possible when you're developing locally.", 'wpcom-thumbnail-editor') . '</p>'; } $html = '<p class="hide-if-js">' . __('You need to enable Javascript to use this functionality.', 'wpcom-thumbnail-editor') . '</p>'; $html .= '<input type="button" class="hide-if-no-js button" onclick="jQuery(this).hide();jQuery(\'#' . esc_js('wpcom-thumbs-' . $attachment->ID) . '\').slideDown(\'slow\');" value="' . __('Show Thumbnails', 'wpcom-thumbnail-editor') . '" />'; $html .= '<div id="' . esc_attr('wpcom-thumbs-' . $attachment->ID) . '" class="hidden">'; $html .= '<p>' . __('Click on a thumbnail image to modify it. Each thumbnail has likely been scaled down in order to fit nicely into a grid.<br /><strong>Only thumbnails that are cropped are shown.</strong> Other sizes are hidden because they will be scaled to fit.', 'wpcom-thumbnail-editor') . '</p>'; $html .= '<div>'; // key wont really matter if its not using a dimension map foreach ($sizes as $key => $size) { $image_name = $this->use_ratio_map ? $key : $size; $edit_url = admin_url('admin.php?action=wpcom_thumbnail_edit&id=' . intval($attachment->ID) . '&size=' . urlencode($size)); // add an extra query var if were using a ratio map if ($this->use_ratio_map) { $edit_url = add_query_arg('ratio', $key, $edit_url); } // We need to get the fullsize thumbnail so that the cropping is properly done $thumbnail = image_downsize($attachment->ID, $size); // Resize the thumbnail to fit into a small box so it's displayed at a reasonable size if (function_exists('jetpack_photon_url')) { $thumbnail_url = jetpack_photon_url($thumbnail[0], array('fit' => array(250, 250))); } else { $thumbnail_url = $thumbnail[0]; } $html .= '<div style="float:left;margin:0 20px 20px 0;min-width:250px;">'; $html .= '<a href="' . esc_url($edit_url) . '"'; if ('media.php' != basename($_SERVER['PHP_SELF'])) { $html .= ' target="_blank"'; } $html .= '>'; $html .= '<strong>' . esc_html($image_name) . '</strong><br />'; $html .= '<img src="' . esc_url($thumbnail_url) . '" alt="' . esc_attr($size) . '" />'; $html .= '</a>'; $html .= '</div>'; } $html .= '</div>'; $html .= '</div>'; return $html; }
/** * Sends an invitation email to a user to join a WordPress.com site. * * @return bool Whether the invitation was sent successfully. */ function resend_wpcom_invite() { global $wpcom_invite_users; $wpcom_invite_users->update_invitation($this->invite->invite_slug, array('invite_date' => gmdate('Y-m-d H:i:s'))); if ('follower' == $this->invite->meta['role'] && !is_private_blog()) { $wpcom_invite_users->invite_followers($this->invite->meta['sent_to']); } else { $wpcom_invite_users->send_invitation($this->invite->invite_slug); } return true; }