Changeset 1718250
- Timestamp:
- 08/23/2017 04:01:02 PM (9 years ago)
- Location:
- thrivehive/trunk
- Files:
-
- 3 edited
-
controllers/core.php (modified) (3 diffs)
-
readme.txt (modified) (5 diffs)
-
thrivehive.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
thrivehive/trunk/controllers/core.php
r1671805 r1718250 200 200 public function get_gallery_images() { 201 201 global $json_api; 202 $selected_ids = json_decode($_REQUEST["selected_ids"]); 203 $selected_id_count = count($selected_ids); 204 $images = array(); 202 205 203 206 if(!current_user_can('upload_files')){ … … 213 216 214 217 if($_REQUEST["count"]){ 215 $ posts_per_page= $_REQUEST["count"];218 $count = $_REQUEST["count"]; 216 219 } 217 220 else{ 218 $ posts_per_page= -1;221 $count = -1; 219 222 } 220 223 … … 226 229 } 227 230 228 $args = array( 229 'post_type' => 'attachment', 230 'post_status' => 'published', 231 'post_mime_type' => $mime_type, 232 'posts_per_page' => $posts_per_page, 233 'numberposts' => null, 234 'offset' => $offset 231 $get_image_args = array( 232 'post_type' => 'attachment', 233 'post_status' => 'published', 234 'post_mime_type' => $mime_type, 235 'numberposts' => null, 236 'offset' => $offset 235 237 ); 236 238 237 $query_images = new WP_Query($args); 238 $images = array(); 239 240 foreach( $query_images->posts as $image) { 239 // If we are passed selected ids, we want to position those first 240 // in the results that we return 241 if ($selected_id_count > 0) { 242 $selected_ids_remaining = $selected_id_count - $offset; 243 244 // Since this endpoint is 'paged', and we are returning the selected 245 // images first, we need to check if there are any more selected ids 246 // on this page 247 if ($selected_ids_remaining > 0) { 248 $should_limit_ids = ($count != -1) && ($selected_ids_remaining > $count); 249 $selected_ids_this_page = ($should_limit_ids ? $count : $selected_ids_remaining); 250 $additional_images_this_page = $count - $selected_ids_this_page; 251 252 // First we get the selected images to return first 253 $selected_image_query = $get_image_args; 254 $selected_image_query['posts_per_page'] = $selected_ids_this_page; 255 $selected_image_query['post__in'] = $selected_ids; 256 $selected_images = new WP_Query($selected_image_query); 257 258 // Then we get additional images to fill the requested number of images 259 if ($additional_images_this_page > 0) { 260 $additional_image_query = $get_image_args; 261 $additional_image_query['posts_per_page'] = $additional_images_this_page; 262 $additional_image_query['post__not_in'] = $selected_ids; 263 $additional_images = new WP_Query($additional_image_query); 264 265 $query_images = new WP_Query(); 266 $query_images->posts = array_merge($selected_images->posts, $additional_images->posts); 267 } else { 268 $query_images = $selected_images; 269 } 270 } 271 // If we have already returned all of the selected images in previous pages 272 // then just return images that do not include selected images 273 else { 274 $not_selected_images_query = $get_image_args; 275 $not_selected_images_query['posts_per_page'] = $count; 276 $not_selected_images_query['post__not_in'] = $selected_ids; 277 $not_selected_images_query['offset'] = max(array(($offset - $selected_id_count), 0)); 278 $query_images = new WP_Query($not_selected_images_query); 279 } 280 } 281 // If we are not passed selected ids, we just return the images in no particular 282 // order 283 else { 284 $images_query = $get_image_args; 285 $images_query['posts_per_page'] = $count; 286 $query_images = new WP_Query($images_query); 287 } 288 289 foreach($query_images->posts as $image) { 241 290 $id = $image->ID; 242 291 $caption = $image->post_excerpt; 243 $image url = wp_get_attachment_url($id);292 $image_url = wp_get_attachment_url($id); 244 293 if(!$_REQUEST["show_pdfs"]){ 245 294 $thumbnail = wp_get_attachment_image_src($id, 'thumbnail'); 246 295 $thumbnail = $thumbnail[0]; 247 $alt text = get_post_meta($id, '_wp_attachment_image_alt', true);296 $alt_text = get_post_meta($id, '_wp_attachment_image_alt', true); 248 297 } 249 298 else{ 250 299 $thumbnail = get_post_meta($id, "th_pdf_thumbnail", true); 251 $alt text = null;252 } 253 254 $images[] = array('id' => $id, 'url' => $image url, 'alt_text' => $alttext, 'thumbnail' => $thumbnail, 'caption' => $caption);300 $alt_text = null; 301 } 302 303 $images[] = array('id' => $id, 'url' => $image_url, 'alt_text' => $alt_text, 'thumbnail' => $thumbnail, 'caption' => $caption); 255 304 } 256 305 return array('images' => $images); -
thrivehive/trunk/readme.txt
r1700353 r1718250 1 === ThriveHive === 1 ThriveHive WordPress Plugin 2 === 3 4 [](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=propelmarketing/warp-prism&utm_campaign=Badge_Grade) 5 2 6 Contributors: thrivehive 3 7 Donate link: … … 11 15 This plugin will automatically instrument a site with ThriveHive's tracking code. 12 16 13 == Description == 17 ## Description 14 18 15 19 This plugin will automatically instrument a site with ThriveHive's tracking code, insert a tracked phone number, and insert a tracked form. 16 20 17 == Installation == 21 ## Installation 18 22 19 23 1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory … … 22 26 4. The tracking code will automatically be added to your site. To insert a phone number, add this PHP to your template in the desired location on your page. get_option ('th_phone_number'). To insert a form, use get_option('th_form_html'). 23 27 24 == Frequently asked questions == 28 ## Frequently asked questions 25 29 1. How do I get the assets to start using this plugin? 26 30 Answer: To get started with ThriveHive, you'll need to create an account with ThriveHive at http://thrivehive.com/free-trial/signup. Once you have an account, go to the account page to get your tracking code (which contains your account ID). ThriveHive will help you get your form HTML and tracked phone lines as well. … … 28 32 Answer: There are two ways to insert the forms and phone numbers. The first uses "shortcodes" which you can use in your pages and posts. Just type [th_form] or [th_phone] in a post or a page and it will pull in the appropriate asset (assuming you have set one up in the ThriveHive plugin settings page. To insert your phone number and form into your php template files, you will need to include <?php th_display_form(); ?> or <?php th_display_form(); >? in your template. 29 33 34 ## Deployment 30 35 36 1. Zip the contents of the repo into a zip named `thrivehive.zip`. So if you are inside the warp-prism folder you can select everything inside and put that into a zip. 37 2. Now you need to initiate an SFTP connection to all of the wordpress servers: 38 - customers.thrivehivesite.com 39 - customers2.thrivehivesite.com 40 - customers3.thrivehivesite.com. 31 41 32 == Screenshots == 42 Creds for these can be accessed from AWS EC2. 43 44 <b>NOTE</b>: EC2 says to use the "WHM KeyPair.pem" file - use the "WHM.pem" file on dropbox instead. 45 46 3. Copy the thrivehive.zip file into `/root/plugins` folder on each of the servers. 47 4. Also on each of the servers copy the contents of the repo (sans `thrivehive.zip`) into `/root/cpanel3-skel/public_html/wp-content/plugins/thrivehive` 48 5. Now that we have all the files on the servers, on each server we can run the script `/scripts/update_thrivehive_plugin.py` 49 6. These scripts may run for a while, but once they are done, all plugins should be up to date! 50 51 ## Screenshots 33 52 34 53 35 54 36 == Changelog == 55 ## Changelog 56 * V 1.137 Fixing bug where data was being returned when no additional images were necessary 37 57 * V 1.136 Fixing bug where drafts that are scheduled are published right away 58 * V 1.135 Hotfix for 1.134 added logic for $currentPostStatus 59 * V 1.134 Fixing bug with published post urls changing when updated 60 * V 1.133 Returning date for blog posts in get_posts endpoint 38 61 * V 1.132 Added paging support for gallery images 39 62 * V 1.131 Adding support for scheduling blog posts … … 148 171 149 172 150 == Upgrade notice == 173 ## Upgrade notice -
thrivehive/trunk/thrivehive.php
r1700353 r1718250 5 5 *Plugin URI: http://thrivehive.com 6 6 *Description: A plugin to include ThriveHive's tracking code 7 *Version: 1.13 67 *Version: 1.137 8 8 *Author: ThriveHive 9 9 *Author URI: http://thrivehive.com
Note: See TracChangeset
for help on using the changeset viewer.