Beispiel #1
0
 /**
  * Get activated activations by license
  *
  * @param \Never5\LicenseWP\License\License $license
  * @param \Never5\LicenseWP\ApiProduct\ApiProduct $api_product
  * @param bool $only_active
  *
  * @return array
  */
 public function get_activations($license, $api_product = null, $only_active = true)
 {
     global $wpdb;
     // dat SQL
     $sql = "SELECT `activation_id` FROM {$wpdb->lwp_activations} WHERE `license_key`=%s";
     // add API product ID if !== null
     if (null !== $api_product) {
         $sql .= $wpdb->prepare(" AND `api_product_id`=%s ", $api_product->get_slug());
     }
     // add if only_active is true
     if ($only_active) {
         $sql .= " AND activation_active = 1";
     }
     $sql .= ";";
     // get activation rows
     $rows = $wpdb->get_results($wpdb->prepare($sql, $license->get_key()));
     // array that stores the api products
     $activations = array();
     // check and loop
     if (is_array($rows) && count($rows) > 0) {
         foreach ($rows as $row) {
             // create ApiProduct objects and store them in array
             $activations[] = license_wp()->service('activation_factory')->make($row->activation_id);
         }
     }
     // return array
     return $activations;
 }
Beispiel #2
0
 /**
  * WordPress update check
  *
  * @param \Never5\LicenseWP\License\License $license
  * @param \Never5\LicenseWP\ApiProduct\ApiProduct $api_product
  * @param array $request
  *
  * @throws ApiException
  */
 private function plugin_information($license, $api_product, $request)
 {
     // transient name
     $transient_name = 'plugininfo_' . md5($request['api_product_id'] . $api_product->get_version());
     // check if transient exists
     if (false === ($data = get_transient($transient_name))) {
         // set data properties
         $data = new \stdClass();
         $data->name = $api_product->get_name();
         $data->plugin = $request['plugin_name'];
         $data->slug = $request['api_product_id'];
         $data->version = $api_product->get_version();
         $data->last_updated = $api_product->get_date();
         // set author
         if ('' != $api_product->get_author_uri()) {
             $data->author = '<a href="' . $api_product->get_author_uri() . '">' . $api_product->get_author() . '</a>';
         } else {
             $data->author = $api_product->get_author();
         }
         // set properties
         $data->requires = $api_product->get_requires_at_least();
         $data->tested = $api_product->get_tested_up_to();
         $data->homepage = $api_product->get_uri();
         // set sections
         $data->sections = array('description' => wpautop(\Parsedown::instance()->text($api_product->get_description())), 'changelog' => \Parsedown::instance()->text($api_product->get_changelog()));
         set_transient($transient_name, $data, DAY_IN_SECONDS);
     }
     // download link
     $data->download_link = $api_product->get_download_url($license);
     // send data
     die(serialize($data));
 }