Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On License management page(for WooCommerce), table heading datas are not displayed properly on SP. #33

Closed
k-kikuchi-waverworks opened this issue Sep 1, 2020 · 2 comments

Comments

@k-kikuchi-waverworks
Copy link

k-kikuchi-waverworks commented Sep 1, 2020

Hello

Thank you for providing this good plugin, so that my business was much better.

On License management page (for WooCommerce), table heading datas are not displayed properly on SP.

WooCommerce display these heading datas for using following css on for small device.

.woocommerce table.shop_table_responsive tr td::before, .woocommerce-page table.shop_table_responsive tr td::before { content: attr(data-title) ": "; font-weight: 700; float: left; }

//https://github.com/michelve/software-license-manager/blob/master/woocommerce/includes/wc_licenses_class.php
However, your code doesn't have "data-title" attribute for tag so that table heading datas are not displayed on SP.
This file should be like this.

`/**

Class SLM_Woo_Account{
public static $endpoint = 'my-licenses';
public function _construct(){
// Actions used to insert a new endpoint in the WordPress.
add_action('init', array($this, 'add_endpoints'));
add_filter('query_vars', array($this, 'add_query_vars'), 0);
// Change the My Accout page title.
add_filter('the_title', array($this, 'endpoint_title'));
// Insering your new tab/page into the My Account page.
add_filter('woocommerce_account_menu_items', array($this, 'slm_woo_menu_list'));
add_action('woocommerce_account
' . self::$endpoint . '_endpoint', array($this, 'endpoint_content'));
}

public function getActiveUser($action){
    $info           = '';
    $current_user   = wp_get_current_user();
    if ($action == 'email') {
        $info = esc_html($current_user->user_email);
    }
    if ($action == 'id') {
        $info =  esc_html($current_user->ID);
    }
    return $info;
}

public function add_endpoints(){
    add_rewrite_endpoint(self::$endpoint, EP_ROOT | EP_PAGES);
}

public function add_query_vars($vars){
    $vars[] = self::$endpoint;
    return $vars;
}

public function endpoint_title($title)
{
    global $wp_query;
    $is_endpoint = isset($wp_query->query_vars[self::$endpoint]);
    if ($is_endpoint && !is_admin() && is_main_query() && in_the_loop() && is_account_page()) {
        // New page title.
        $title = __('My Licenses', 'softwarelicensemanager');
        remove_filter('the_title', array($this, 'endpoint_title'));
    }
    return $title;
}

public function slm_woo_menu_list($items){
    // Remove the logout menu item.
    $logout = $items['customer-logout'];
    unset($items['customer-logout']);
    // Insert your custom endpoint.
    $items[self::$endpoint] = __('My Licenses', 'softwarelicensemanager');
    // Insert back the logout item.
    $items['customer-logout'] = $logout;
    return $items;
}

public function endpoint_content(){
    global $wpdb, $wp_query;
    $slm_options = get_option('slm_plugin_options');
    $allow_domain_removal = $slm_options['allow_user_activation_removal']==1 ? true : false;
    $class_ = 0;
    $class_id_ = 0;
    $get_user_info = $get_user_email = '';
    // get user billing email
    $wc_billing_email = get_user_meta(get_current_user_id(), 'billing_email', true);

    // if wp billing is empty
    if ($wc_billing_email == '') {
        $wc_billing_email   = get_userdata(get_current_user_id())->user_email;
    }
    $result = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_key_tbl WHERE email='" . $wc_billing_email . "' ORDER BY `email` DESC LIMIT 0,1000");
    $slm_hide = '';

    if(empty($result)){
        echo '<div class="woocommerce-Message woocommerce-Message--info woocommerce-info"> <a class="woocommerce-Button button" href="'.get_permalink( wc_get_page_id( 'shop' ) ).'"> Browse products		</a> No licenses available yet.	</div>';
        $slm_hide = 'style="display:none"';
    }
    ?>

    <div class="woocommerce-slm-content" <?php echo $slm_hide;?>>
        <table id="slm_licenses_table" class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table" style="border-collapse:collapse;">
            <thead>
                <tr>
                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Order', 'softwarelicensemanager');?></th>
                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Status', 'softwarelicensemanager');?></th>
                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Product', 'softwarelicensemanager');?></th>
                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('License Key', 'softwarelicensemanager');?></th>
                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Renews on', 'softwarelicensemanager');?></th>
                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Info', 'softwarelicensemanager');?></th>
                </tr>
            </thead>
            <tbody>
                <?php
                    foreach ($result as $license_info) : ?>
                        <tr data-toggle="collapse" data-target=".demo<?php echo $class_++; ?>" class="woocommerce-orders-table__row woocommerce-orders-table__row--status-completed order">
                            <td class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-number slm-order" data-title="<?php echo __('Order', 'softwarelicensemanager'); ?>"><a href="<?php echo get_site_url() . '/my-account/view-order/' . $license_info->purchase_id_; ?>">#<?php echo $license_info->purchase_id_; ?></a></td>

                            <td class="slm-status" data-title="<?php echo __('Status', 'softwarelicensemanager'); ?>">
                                <?php $key_status = $license_info->lic_status; ?>
                                <div class="slm-key-status"> <span class="key-status <?php echo $key_status; ?>"><?php echo $key_status; ?></span></div>
                            </td>

                            <td class="slm-product-reference" data-title="<?php echo __('Product', 'softwarelicensemanager'); ?>">
                            <?php
                                $product_id     = $license_info->product_ref;
                                $product_name   = get_the_title($product_id);

                                if(!empty($product_name) && isset($product_name)){
                                    echo '<a href="'. get_permalink($product_id).'"> ' . $product_name . '</a>';
                                }
                            ?>
                            </td>

                            <td class="slm-key" data-title="<?php echo __('License Key', 'softwarelicensemanager'); ?>"><?php echo $license_info->license_key; ?></td>

                            <td class="slm-renewal" data-title="<?php echo __('Renews on', 'softwarelicensemanager'); ?>">
                                <?php
                                    $expiration = new DateTime($license_info->date_expiry);
                                    $today      = new DateTime();

                                    if ($license_info->lic_type == 'subscription' && $license_info->date_expiry != '0000-00-00'){
                                        if($expiration < $today){
                                            echo "<span style='color: red'><strong>Expired</strong></span>";
                                        }
                                        else {
                                            echo $license_info->date_expiry;
                                        }
                                    }
                                    else {
                                        echo "Lifetime";
                                    }
                                ?>

                            </td>

                            <td class="slm-view" data-title="<?php echo __('Info', 'softwarelicensemanager'); ?>"><a href="#" class="woocommerce-button button view"><?php echo __('View', 'softwarelicensemanager');?></a></td>
                        </tr>

                        <tr class="parent">
                            <td colspan="5" class="hiddenRow">
                                <div class="collapse demo<?php echo $class_id_++; ?> slm-shadow">

                                    <div class="slm_ajax_msg"></div>

                                    <?php
                                    global $wpdb;
                                    $detailed_license_info =  $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_key_tbl WHERE `license_key` = '" . $license_info->license_key . "' ORDER BY `id` LIMIT 0,1000;", ARRAY_A);

                                    $detailed_domain_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_reg_domain_tbl WHERE `lic_key` = '" . $license_info->license_key . "' ORDER BY `lic_key_id` LIMIT 0,1000;", ARRAY_A);

                                    $detailed_devices_info =  $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_reg_devices_tbl WHERE `lic_key` = '" . $license_info->license_key . "' ORDER BY `lic_key_id` LIMIT 0,1000;", ARRAY_A);
                                    ?>
                                    <div class="row" style="padding: 16px;">
                                        <table>
                                            <thead>
                                                <tr>
                                                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Expiration', 'softwarelicensemanager');?></th>
                                                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Allowed Devices', 'softwarelicensemanager');?></th>
                                                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Allowed Domains', 'softwarelicensemanager');?></th>
                                                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('License type', 'softwarelicensemanager');?></th>
                                                    <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Date renewed', 'softwarelicensemanager');?></th>
                                                     <th class="woocommerce-orders-table__header woocommerce-orders-table__header-order-number"><?php echo __('Activation date', 'softwarelicensemanager');?></th>
                                                </tr>
                                            </thead>
                                            <tr>
                                                <td data-title=<?php echo __('Expiration', 'softwarelicensemanager'); ?> class="slm-expiration"><time datetime="<?php echo $license_info->date_expiry; ?>"><?php echo $license_info->date_expiry; ?></time></td>
                                                <td data-title=<?php echo __('Allowed Devices', 'softwarelicensemanager'); ?>><?php echo $license_info->max_allowed_devices; ?></td>
                                                <td data-title=<?php echo __('Allowed Domains', 'softwarelicensemanager'); ?>><?php echo $license_info->max_allowed_domains; ?></td>
                                                <td data-title=<?php echo __('License type', 'softwarelicensemanager'); ?>><?php echo $license_info->lic_type; ?></td>
                                                <td data-title=<?php echo __('Date renewed', 'softwarelicensemanager'); ?>><?php echo $license_info->date_renewed; ?></td>
                                                <td data-title=<?php echo __('Activation date', 'softwarelicensemanager'); ?>><?php echo $license_info->date_activated; ?></td>
                                            </tr>
                                        </table>

                                        <br>
                                        <div class="row" style="width: 100%;">
                                            <div class="slm-activated-on domains-list col-md-6">
                                                <?php SLM_Utility::get_license_activation($license_info->license_key, SLM_TBL_LIC_DOMAIN, __('Domains', 'softwarelicensemanager'), $allow_domain_removal); ?>
                                            </div>

                                            <div class="slm-activated-on domains-list col-md-6">
                                                <?php SLM_Utility::get_license_activation($license_info->license_key, SLM_TBL_LIC_DEVICES, __('Devices', 'softwarelicensemanager'), $allow_domain_removal); ?>
                                            </div>
                                        </div>
                                        <div class="clear"></div>

                                        <div class="row slm-export">
                                            <?php
                                                $license_key_json_data  = json_encode(array_values($detailed_license_info));
                                            ?>
                                            <div class="col-md-12 slm-action-export">
                                                <input type="button" id="export-lic-key" data-licdata='<?php echo $license_key_json_data;?>' value="<?php echo __('Export license', 'softwarelicensemanager');?>" class="btn btn-secondary slm-button" />
                                            </div>
                                        </div>
                                    </div>

                                    <div class="clear"></div>

                                </div>
                            </td>
                        </tr>

                    <?php endforeach;
                ?>
            </tbody>
        </table>
    </div>
    <?php
    if($allow_domain_removal == true):
    ?>
    <script>
        jQuery(document).ready(function() {
            jQuery('.deactivate_lic_key').click(function(event) {
                var id          = jQuery(this).attr("id");
                var lic_type    = jQuery(this).attr('lic_type');
                var class_name  = '.lic-entry-' + id;

                jQuery(this).text('Removing');
                jQuery.get('<?php echo get_bloginfo("url"); ?>' + '/wp-admin/admin-ajax.php?action=del_activation&id=' + id +'&lic_type=' + lic_type, function(data) {
                    if (data == 'success') {
                        jQuery(class_name).remove();
                        jQuery('.slm_ajax_msg').html('<div class="alert alert-primary" role="alert"><?php echo __('License key was deactivated!', 'softwarelicensemanager');?> </div>');
                    }
                    else {
                        jQuery('.slm_ajax_msg').html('<div class="alert alert-danger" role="alert"><?php echo __('License key was not deactivated!', 'softwarelicensemanager');?></div>');
                    }
                });
            });
        });
    </script>
    <?php
    endif;

}

/**

  • Plugin install action.
  • Flush rewrite rules to make our custom endpoint available.
    */
    public static function install(){
    flush_rewrite_rules();
    }
    }
    new SLM_Woo_Account();

// Flush rewrite rules on plugin activation.
register_activation_hook(FILE, array('Doc', 'install'));
`

Please check the parts of "data-title" attributes.

KIng Regards

KAZUKI

@k-kikuchi-waverworks k-kikuchi-waverworks changed the title On License management page(for WooCommerce), the heading text in <th> is not displayed properly on SP. On License management page(for WooCommerce), table heading datas are not displayed properly on SP. Sep 1, 2020
@michelve
Copy link
Owner

michelve commented Sep 1, 2020

thx @k-kikuchi-idea-hack - i will merge this for the next release.

@michelve
Copy link
Owner

michelve commented Sep 1, 2020

fixed: #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants