예제 #1
0
 /**
  * This saves the value.
  *
  * @since 1.0
  */
 public function save_feature_on_product_save()
 {
     // Abort if we don't have a product ID
     $product_id = empty($_POST['ID']) ? false : $_POST['ID'];
     if (!$product_id) {
         return;
     }
     $prev = it_exchange_get_product_feature($product_id, $this->slug);
     $data = $_POST['itelic'];
     $data['enabled'] = isset($data['enabled']) ? it_exchange_str_true($data['enabled']) : false;
     $data['enabled_variant_activations'] = isset($data['enabled_variant_activations']) ? it_exchange_str_true($data['enabled_variant_activations']) : false;
     $data['online-software'] = isset($data['online-software']) ? it_exchange_str_true($data['online-software']) : false;
     if (!empty($prev['version'])) {
         unset($data['version']);
     }
     $first_release = get_post_meta($product_id, '_itelic_first_release', true);
     if (!$first_release && isset($data['update-file']) && $data['update-file']) {
         $download = $data['update-file'];
         $download_meta = get_post_meta($download, '_it-exchange-download-info', true);
         if (empty($download_meta)) {
             return;
         }
         $url = $download_meta['source'];
         /**
          * @var \wpdb $wpdb
          */
         global $wpdb;
         $ID = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid = %s", $url));
         $file = get_post($ID);
         if ($file->post_type == 'attachment') {
             $product = itelic_get_product($product_id);
             if (isset($data['version'])) {
                 $version = $data['version'];
             } elseif (isset($prev['version'])) {
                 $version = $prev['version'];
             } else {
                 $version = '';
             }
             $type = Release::TYPE_MAJOR;
             $status = get_post_status($product_id) == 'publish' ? Release::STATUS_ACTIVE : Release::STATUS_DRAFT;
             $changelog = '<ul><li>' . __("Initial release.", Plugin::SLUG) . '</li></ul>';
             if ($version) {
                 try {
                     $args = array('product' => $product, 'file' => $file, 'version' => $version, 'type' => $type, 'status' => $status, 'changelog' => $changelog);
                     $release = itelic_create_release($args);
                     if ($release && !is_wp_error($release)) {
                         update_post_meta($product_id, '_itelic_first_release', $release->get_pk());
                     }
                 } catch (\Exception $e) {
                 }
             }
         }
     }
     it_exchange_update_product_feature($product_id, $this->slug, $data);
 }
예제 #2
0
 /**
  * This saves the value.
  *
  * @since 1.0
  */
 public function save_feature_on_product_save()
 {
     // Abort if we don't have a product ID
     $product_id = empty($_POST['ID']) ? false : $_POST['ID'];
     if (!$product_id) {
         return;
     }
     $data = $_POST['itelic_upgrade'];
     $data['enable'] = isset($data['enable']) ? it_exchange_str_true($data['enable']) : false;
     it_exchange_update_product_feature($product_id, $this->slug, $data);
 }
예제 #3
0
 /**
  * This saves the value.
  *
  * @since 1.0
  */
 public function save_feature_on_product_save()
 {
     // Abort if we don't have a product ID
     $product_id = empty($_POST['ID']) ? false : $_POST['ID'];
     if (!$product_id) {
         return;
     }
     $data = $_POST['itelic_readme'];
     $data['enable'] = isset($data['enable']) ? it_exchange_str_true($data['enable']) : false;
     $last_updated = \ITELIC\make_local_time($data['last_updated']);
     $data['last_updated'] = $last_updated->getTimestamp();
     it_exchange_update_product_feature($product_id, $this->slug, $data);
 }