Skip to content

Commit

Permalink
resolved bootstrap issues and conflicts
Browse files Browse the repository at this point in the history
resolved bootstrap issues and conflicts with woocommerce
  • Loading branch information
michelve committed Sep 2, 2020
1 parent 8306c65 commit 68481ce
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 108 deletions.
133 changes: 71 additions & 62 deletions admin/slm-lic-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,82 @@
die;
}

function slm_settings_menu(){
function slm_settings_menu()
{
slm_general_settings();
}

function slm_general_settings(){
?>
function slm_general_settings()
{
?>
<?php

if (isset($_REQUEST['slm_reset_log'])) {
$slm_logger = new SLM_Debug_Logger();
global $slm_debug_logger;
$slm_debug_logger->reset_log_file("log.txt");
$slm_debug_logger->reset_log_file("log-cron-job.txt");
echo '<div id="message" class="updated fade"><p>
'.__( 'Debug log files have been reset!', 'softwarelicensemanager' ) .'
if (isset($_REQUEST['slm_reset_log'])) {
$slm_logger = new SLM_Debug_Logger();
global $slm_debug_logger;
$slm_debug_logger->reset_log_file("log.txt");
$slm_debug_logger->reset_log_file("log-cron-job.txt");
echo '<div id="message" class="updated fade"><p>
' . __('Debug log files have been reset!', 'softwarelicensemanager') . '
</p></div>';
}

if (isset($_POST['slm_save_settings'])) {
}

if (!is_numeric($_POST["default_max_domains"])) {
//Set it to one by default if incorrect value is entered
$_POST["default_max_domains"] = '2';
}
if (!is_numeric($_POST["default_max_devices"])) {
//Set it to one by default if incorrect value is entered
$_POST["default_max_devices"] = '2';
}
if (isset($_POST['slm_save_settings'])) {

$options = array(
'lic_creation_secret' => trim($_POST["lic_creation_secret"]),
'lic_prefix' => trim($_POST["lic_prefix"]),
'default_max_domains' => trim($_POST["default_max_domains"]),
'default_max_devices' => trim($_POST["default_max_devices"]),
'lic_verification_secret' => trim($_POST["lic_verification_secret"]),
'enable_auto_key_expiration' => isset($_POST['enable_auto_key_expiration']) ? '1' : '',
'enable_debug' => isset($_POST['enable_debug']) ? '1' : '',
'slm_woo' => isset($_POST['slm_woo']) ? '1' : '',
'slm_woo_downloads' => isset($_POST['slm_woo_downloads']) ? '1' : '',
'slm_woo_affect_downloads' => isset($_POST['slm_woo_affect_downloads']) ? '1' : '',
'slm_stats' => isset($_POST['slm_stats']) ? '1' : '',
'slm_adminbar' => isset($_POST['slm_adminbar']) ? '1' : '',
'slm_conflictmode' => isset($_POST['slm_conflictmode']) ? '1' : '',
'slm_wpestores' => isset($_POST['slm_wpestores']) ? '1' : '',
'slm_dl_manager' => isset($_POST['slm_dl_manager']) ? '1' : '',
'slm_multiple_items' => isset($_POST['slm_multiple_items']) ? '1' : '',
'allow_user_activation_removal' => isset($_POST['allow_user_activation_removal']) ? '1' : '',
'expiration_reminder_text' => sanitize_text_field($_POST['expiration_reminder_text'])
);
update_option('slm_plugin_options', $options);

echo ' <div id="message" class="updated fade"> <p>'.__( 'Options updated!', 'softwarelicensemanager' ).'</p> </div>';
if (!is_numeric($_POST["default_max_domains"])) {
//Set it to one by default if incorrect value is entered
$_POST["default_max_domains"] = '2';
}
if (!is_numeric($_POST["default_max_devices"])) {
//Set it to one by default if incorrect value is entered
$_POST["default_max_devices"] = '2';
}

$options = get_option('slm_plugin_options');
$secret_key = $options['lic_creation_secret'];
$options = array(
'lic_creation_secret' => trim($_POST["lic_creation_secret"]),
'lic_prefix' => trim($_POST["lic_prefix"]),
'default_max_domains' => trim($_POST["default_max_domains"]),
'default_max_devices' => trim($_POST["default_max_devices"]),
'lic_verification_secret' => trim($_POST["lic_verification_secret"]),
'enable_auto_key_expiration' => isset($_POST['enable_auto_key_expiration']) ? '1' : '',
'enable_debug' => isset($_POST['enable_debug']) ? '1' : '',
'slm_woo' => isset($_POST['slm_woo']) ? '1' : '',
'slm_woo_downloads' => isset($_POST['slm_woo_downloads']) ? '1' : '',
'slm_woo_affect_downloads' => isset($_POST['slm_woo_affect_downloads']) ? '1' : '',
'slm_stats' => isset($_POST['slm_stats']) ? '1' : '',
'slm_adminbar' => isset($_POST['slm_adminbar']) ? '1' : '',
'slm_conflictmode' => isset($_POST['slm_conflictmode']) ? '1' : '',
'slm_front_conflictmode' => isset($_POST['slm_front_conflictmode']) ? '1' : '',
'slm_wpestores' => isset($_POST['slm_wpestores']) ? '1' : '',
'slm_dl_manager' => isset($_POST['slm_dl_manager']) ? '1' : '',
'slm_multiple_items' => isset($_POST['slm_multiple_items']) ? '1' : '',
'allow_user_activation_removal' => isset($_POST['allow_user_activation_removal']) ? '1' : '',
'expiration_reminder_text' => sanitize_text_field($_POST['expiration_reminder_text'])
);
update_option('slm_plugin_options', $options);

echo ' <div id="message" class="updated fade"> <p>' . __('Options updated!', 'softwarelicensemanager') . '</p> </div>';
}

if (empty($secret_key)) {
//$secret_key = md5(uniqid('', true));
$secret_key = SLM_Utility::create_secret_keys();
}
$options = get_option('slm_plugin_options');
$secret_key = $options['lic_creation_secret'];

$secret_verification_key = $options['lic_verification_secret'];
if (empty($secret_verification_key)) {
//$secret_verification_key = md5(uniqid('', true));
$secret_verification_key = SLM_Utility::create_secret_keys();
}
$tab = ""; //Initialization value;
if (isset($_REQUEST['tab'])) {
$tab = $_REQUEST['tab'];
} else {
$tab = 'general_settings';
}
if (empty($secret_key)) {
//$secret_key = md5(uniqid('', true));
$secret_key = SLM_Utility::create_secret_keys();
}

$secret_verification_key = $options['lic_verification_secret'];
if (empty($secret_verification_key)) {
//$secret_verification_key = md5(uniqid('', true));
$secret_verification_key = SLM_Utility::create_secret_keys();
}
$tab = ""; //Initialization value;
if (isset($_REQUEST['tab'])) {
$tab = $_REQUEST['tab'];
} else {
$tab = 'general_settings';
}

?>
<div class="wrap">
Expand Down Expand Up @@ -199,6 +202,12 @@ function slm_general_settings(){
<input name="slm_conflictmode" type="checkbox" <?php if ($options['slm_conflictmode'] != '') echo ' checked="checked"'; ?> value="1" />
<?php _e('Enable Bootstrap javascript libray.', 'softwarelicensemanager'); ?></td>
</tr>
<tr>
<th scope="row"></th>
<td>
<input name="slm_front_conflictmode" type="checkbox" <?php if ($options['slm_front_conflictmode'] != '') echo ' checked="checked"'; ?> value="1" />
<?php _e('Enable Bootstrap javascript libray in front-end (woocommerce pages, etc).', 'softwarelicensemanager'); ?></td>
</tr>

</table>
</div>
Expand Down Expand Up @@ -279,4 +288,4 @@ function slm_general_settings(){
</form>
</div>
<?php
}
}
66 changes: 34 additions & 32 deletions includes/class-slm-installer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Runs on Uninstall of Software License Manager
*
Expand All @@ -18,17 +19,16 @@
$lic_emails_table = SLM_TBL_EMAILS;

//***Database version check */
$used_db_version = get_option( 'slm_db_version', SLM_DB_VERSION);
$used_db_version = get_option('slm_db_version', SLM_DB_VERSION);

$charset_collate = '';
if (!empty($wpdb->charset)){
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
}
else{
$charset_collate = "DEFAULT CHARSET=utf8";
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
} else {
$charset_collate = "DEFAULT CHARSET=utf8";
}
if (!empty($wpdb->collate)){
$charset_collate .= " COLLATE $wpdb->collate";
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE $wpdb->collate";
}

$lk_tbl_sql = "CREATE TABLE " . $lic_key_table . " (
Expand Down Expand Up @@ -80,12 +80,12 @@
foreach ($item_result as $reference_item) {
$item_id = $reference_item->id;
// update and set default value
$update_reference = "UPDATE $lic_key_table SET item_reference='default' WHERE id='".$item_id."';";
$update_reference = "UPDATE $lic_key_table SET item_reference='default' WHERE id='" . $item_id . "';";
dbDelta($update_reference);
}
}

$ld_tbl_sql = "CREATE TABLE " .$lic_domain_table. " (
$ld_tbl_sql = "CREATE TABLE " . $lic_domain_table . " (
id INT NOT NULL AUTO_INCREMENT ,
lic_key_id INT NOT NULL ,
lic_key varchar(255) NOT NULL ,
Expand Down Expand Up @@ -120,7 +120,7 @@
)" . $charset_collate . ";";
dbDelta($log_tbl_sql);

$ldv_tbl_sql = "CREATE TABLE " .$lic_devices_table. " (
$ldv_tbl_sql = "CREATE TABLE " . $lic_devices_table . " (
id INT NOT NULL AUTO_INCREMENT ,
lic_key_id INT NOT NULL ,
lic_key varchar(255) NOT NULL ,
Expand All @@ -133,31 +133,33 @@

// Add default options
$options = array(
'lic_creation_secret' => SLM_Utility::create_secret_keys(),
'lic_prefix' => 'SLM-',
'default_max_domains' => '2',
'default_max_devices' => '2',
'lic_verification_secret' => SLM_Utility::create_secret_keys(),
'enable_debug' => '',
'slm_woo' => '1',
'slm_woo_downloads' => '',
'slm_woo_affect_downloads'=> '1',
'slm_wpestores' => '',
'slm_stats' => '1',
'slm_adminbar' => '1',
'slm_multiple_items' => '',
'slm_conflictmode' => '1',
'enable_auto_key_expiration' => '1',
'slm_dl_manager' => '',
'allow_user_activation_removal' => '1',
'expiration_reminder_text' => 'Your account has reverted to Basic with limited functionality. Renew today to keep using it on all of your devices and enjoy the valuable features. It鈥檚 a smart investment');
'lic_creation_secret' => SLM_Utility::create_secret_keys(),
'lic_prefix' => 'SLM-',
'default_max_domains' => '2',
'default_max_devices' => '2',
'lic_verification_secret' => SLM_Utility::create_secret_keys(),
'enable_debug' => '',
'slm_woo' => '1',
'slm_woo_downloads' => '',
'slm_woo_affect_downloads' => '1',
'slm_wpestores' => '',
'slm_stats' => '1',
'slm_adminbar' => '1',
'slm_multiple_items' => '',
'slm_conflictmode' => '1',
'slm_front_conflictmode' => '1',
'enable_auto_key_expiration' => '1',
'slm_dl_manager' => '',
'allow_user_activation_removal' => '1',
'expiration_reminder_text' => 'Your account has reverted to Basic with limited functionality. Renew today to keep using it on all of your devices and enjoy the valuable features. It鈥檚 a smart investment'
);

//Bugfix - Prevention of overwriting existing settings
// thanks to @MechComp
$old_options = get_option('slm_plugin_options');
if($old_options != false){
$options = array_merge($options,$old_options);
if ($old_options != false) {
$options = array_merge($options, $old_options);
}

update_option('slm_plugin_options', $options);
update_option("slm_db_version", SLM_DB_VERSION);
update_option("slm_db_version", SLM_DB_VERSION);
25 changes: 13 additions & 12 deletions includes/slm-scripts.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
<?php

// add admin styles and scipts
function slm_admin_assets() {
wp_enqueue_style('softwarelicensemanager', SLM_ASSETS_URL .'css/slm.css');
wp_enqueue_script('slm_validate', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js', array('jquery'), '1.19.0', true);
wp_enqueue_script('slm_validate_js', SLM_ASSETS_URL .'js/slm.js', array('jquery'), '1.0.1', true );
function slm_admin_assets()
{
wp_enqueue_style('softwarelicensemanager', SLM_ASSETS_URL . 'css/slm.css');
wp_enqueue_script('slm_validate', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js', array('jquery'), '1.19.0', true);
wp_enqueue_script('slm_validate_js', SLM_ASSETS_URL . 'js/slm.js', array('jquery'), '1.0.1', true);
}

// load frontend styles
function slm_js_license(){
function slm_js_license()
{
wp_enqueue_script('slm_js', SLM_ASSETS_URL . 'js/slm-js.js', array('jquery'), '1.0.1', true);
}

function slm_frontend_assets() {
function slm_frontend_assets()
{
/**
* Check if WooCommerce is activated
*/
if (is_plugin_active('woocommerce/woocommerce.php')) {
if (is_plugin_active('woocommerce/woocommerce.php')) {

if(is_account_page()) {
if (is_account_page() && SLM_Helper_Class::slm_get_option('slm_front_conflictmode') == 1) {
wp_enqueue_style('bootstrapcdn-slm', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css');
wp_enqueue_script('bootstrapcdn-slm-js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js', array('jquery'), '4.1.3', true);
}

}
// custom css
wp_enqueue_style('softwarelicensemanager', SLM_ASSETS_URL .'css/slm-front-end.css');
wp_enqueue_style('softwarelicensemanager', SLM_ASSETS_URL . 'css/slm-front-end.css');
}

add_action('wp_enqueue_scripts', 'slm_frontend_assets');
//add_action('wp_enqueue_scripts', 'slm_frontend_assets');
add_action('admin_enqueue_scripts', 'slm_admin_assets');



/**
* Check if WooCommerce is activated
*/
Expand Down
4 changes: 2 additions & 2 deletions software-license-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

//Short name/slug "SLM" or "slm"
define('SLM_VERSION', '5.5.6');
define('SLM_DB_VERSION', '4.2.8');
define('SLM_REWRITE_VERSION', '2.3.9');
define('SLM_DB_VERSION', '4.2.9');
define('SLM_REWRITE_VERSION', '2.4.0');
define('SLM_FOLDER', dirname(plugin_basename(__FILE__)));
define('SLM_URL', plugins_url('', __FILE__));
define('SLM_ASSETS_URL', SLM_URL . '/public/assets/');
Expand Down
6 changes: 6 additions & 0 deletions woocommerce/includes/wc_licenses_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public function endpoint_content()
}
?>

<?php
if (SLM_Helper_Class::slm_get_option('slm_front_conflictmode') == 1) : ?>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<?php endif; ?>

<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>
Expand Down

0 comments on commit 68481ce

Please sign in to comment.