Пример #1
0
 /**
  * Column default
  *
  * @access public
  *
  * @param object $item
  * @param array $column_name
  *
  * @return string
  */
 public function column_default($item, $column_name)
 {
     global $wpdb;
     switch ($column_name) {
         case 'license_key':
             return '<a href="' . admin_url('admin.php?page=license_wp_licenses&amp;edit=' . $item->license_key) . '"><code>' . $item->license_key . '</code></a>';
         case 'activation_email':
             return $item->activation_email;
         case 'product_id':
             $product = WooCommerce\Product::get_product($item->product_id);
             return $product ? '<a href="' . admin_url('post.php?post=' . absint($product->ID) . '&action=edit') . '">' . esc_html($product->post_title) . '</a>' : __('n/a', 'license-wp');
         case 'user_id':
             return $item->user_id ? '<a href="' . admin_url('user-edit.php?user_id=' . absint($item->user_id)) . '">#' . esc_html($item->user_id) . '&rarr;</a>' : __('n/a', 'license-wp');
         case 'activations':
             $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT( activation_id ) FROM {$wpdb->lwp_activations} WHERE activation_active = 1 AND license_key=%s;", $item->license_key));
             return '<a href="' . admin_url('admin.php?page=license_wp_activations&amp;license_key=' . $item->license_key) . '">' . absint($count) . ' &rarr;</a>';
         case 'activation_limit':
             return $item->activation_limit ? sprintf(__('%d per product', 'license-wp'), absint($item->activation_limit)) : __('n/a', 'license-wp');
         case 'order_id':
             return $item->order_id > 0 ? '<a href="' . admin_url('post.php?post=' . absint($item->order_id) . '&action=edit') . '">#' . absint($item->order_id) . ' &rarr;</a>' : __('n/a', 'license-wp');
         case 'date_created':
             return $item->date_created > 0 ? date_i18n(get_option('date_format'), strtotime($item->date_created)) : __('n/a', 'license-wp');
         case 'date_expires':
             return $item->date_expires > 0 ? date_i18n(get_option('date_format'), strtotime($item->date_expires)) : __('n/a', 'license-wp');
     }
 }
Пример #2
0
    _e('Activation limit', 'license-wp');
    ?>
</th>
			<th><?php 
    _e('Download/Renew', 'license-wp');
    ?>
</th>
		</tr>
		</thead>
		<tbody>
		<?php 
    foreach ($licenses as $license) {
        /** @var \Never5\LicenseWP\License\License $license */
        $license = $license;
        // get the WooCommere product
        $wc_product = \Never5\LicenseWP\WooCommerce\Product::get_product($license->get_product_id());
        // get activations
        $activations = $license->get_activations();
        ?>
			<tr>
				<td rowspan="<?php 
        echo sizeof($activations) + 1;
        ?>
"><?php 
        echo esc_html($wc_product->post_title);
        ?>
</td>
				<td>
					<code style="display:block;"><?php 
        echo $license->get_key();
        ?>