Plugin Directory

Changeset 1718250


Ignore:
Timestamp:
08/23/2017 04:01:02 PM (9 years ago)
Author:
thrivehive
Message:

v 1.137

Location:
thrivehive/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • thrivehive/trunk/controllers/core.php

    r1671805 r1718250  
    200200  public function get_gallery_images() {
    201201    global $json_api;
     202    $selected_ids = json_decode($_REQUEST["selected_ids"]);
     203    $selected_id_count = count($selected_ids);
     204    $images = array();
    202205
    203206    if(!current_user_can('upload_files')){
     
    213216
    214217    if($_REQUEST["count"]){
    215       $posts_per_page = $_REQUEST["count"];
     218      $count = $_REQUEST["count"];
    216219    }
    217220    else{
    218       $posts_per_page = -1;
     221      $count = -1;
    219222    }
    220223
     
    226229    }
    227230
    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
    235237    );
    236238
    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) {
    241290      $id = $image->ID;
    242291      $caption = $image->post_excerpt;
    243       $imageurl = wp_get_attachment_url($id);
     292      $image_url = wp_get_attachment_url($id);
    244293      if(!$_REQUEST["show_pdfs"]){
    245294        $thumbnail = wp_get_attachment_image_src($id, 'thumbnail');
    246295        $thumbnail = $thumbnail[0];
    247         $alttext = get_post_meta($id, '_wp_attachment_image_alt', true);
     296        $alt_text = get_post_meta($id, '_wp_attachment_image_alt', true);
    248297      }
    249298      else{
    250299        $thumbnail = get_post_meta($id, "th_pdf_thumbnail", true);
    251         $alttext = null;
    252       }
    253 
    254       $images[] = array('id' => $id, 'url' => $imageurl, '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);
    255304    }
    256305    return array('images' => $images);
  • thrivehive/trunk/readme.txt

    r1700353 r1718250  
    1 === ThriveHive ===
     1ThriveHive WordPress Plugin
     2===
     3
     4[![Codacy Badge](https://api.codacy.com/project/badge/Grade/19101fbe71794f45aa08af8a141eb7b4)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=propelmarketing/warp-prism&utm_campaign=Badge_Grade)
     5
    26Contributors: thrivehive
    37Donate link:
     
    1115This plugin will automatically instrument a site with ThriveHive's tracking code.
    1216
    13 == Description ==
     17## Description
    1418
    1519This plugin will automatically instrument a site with ThriveHive's tracking code, insert a tracked phone number, and insert a tracked form.
    1620
    17 == Installation ==
     21## Installation
    1822
    19231. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
     
    22264. 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').
    2327
    24 == Frequently asked questions ==
     28## Frequently asked questions
    25291. How do I get the assets to start using this plugin?
    2630Answer: 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.
     
    2832Answer: 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.
    2933
     34## Deployment
    3035
     361. 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.
     372. 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.
    3141
    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
     463. Copy the thrivehive.zip file into `/root/plugins` folder on each of the servers.
     474. 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`
     485. Now that we have all the files on the servers, on each server we can run the script `/scripts/update_thrivehive_plugin.py`
     496. These scripts may run for a while, but once they are done, all plugins should be up to date!
     50
     51## Screenshots
    3352
    3453
    3554
    36 == Changelog ==
     55## Changelog
     56* V 1.137 Fixing bug where data was being returned when no additional images were necessary
    3757* 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
    3861* V 1.132 Added paging support for gallery images
    3962* V 1.131 Adding support for scheduling blog posts
     
    148171
    149172
    150 == Upgrade notice ==
     173## Upgrade notice
  • thrivehive/trunk/thrivehive.php

    r1700353 r1718250  
    55   *Plugin URI: http://thrivehive.com
    66   *Description: A plugin to include ThriveHive's tracking code
    7    *Version: 1.136
     7   *Version: 1.137
    88   *Author: ThriveHive
    99   *Author URI: http://thrivehive.com
Note: See TracChangeset for help on using the changeset viewer.