public static function createBehaviourChangeNotice($since, $message) { $shortHtml = "Behavior of WooCommerce Weight Based Shipping changed since {$since}."; $longHtml = '<p>' . esc_html($message) . '</p> <p>' . 'Please <a href="' . esc_html(WbsRuleUrls::generic()) . '">review settings</a> and make appropriate changes if it\'s needed.' . '</p>'; return new self($shortHtml, $longHtml); }
public function show() { static $firstRun = true; $data = $this->load(); /** @var WBS_Upgrade_Notice $notice */ foreach ($data['notices'] as $id => $notice) { $hideNoticeUrl = esc_html(WbsRuleUrls::generic(array($this->removeNoticeUrlFlagName => $id))); echo ' <div class="woowbs-upgrade-notice highlight" style="padding: 1em; border: 1px solid red;"> <big>' . $notice->getShortHtml() . ' <a class="woowbs-upgrade-notice-switcher" href="#">Less</a> </big> <div class="woowbs-upgrade-notice-long-message">' . $notice->getLongHtml() . ' <p><a class="button" href="' . $hideNoticeUrl . '">Don\'t show this message again</a></p> </div> </div> '; if ($firstRun) { $firstRun = false; echo ' <script> jQuery(function($) { var toggleSpeed = 0; var $collapsers = $(".woowbs-upgrade-notice-switcher"); $collapsers.click(function() { var $collapser = $(this); var $content = $collapser .closest(".woowbs-upgrade-notice") .find(".woowbs-upgrade-notice-long-message"); $content.toggle(toggleSpeed, function() { $collapser.text($content.is(":visible") ? "Less" : "More"); }); return false; }); $collapsers.click(); toggleSpeed = "fast"; }); </script> '; } } }
private static function listProfiles(array $profiles) { $current_profile_id = WBS_Profile_Manager::instance()->current_profile_id(); ?> <table id="woowbs_shipping_methods" class="wc_shipping widefat"> <thead> <tr> <th class="name"> <?php esc_html_e('Name', 'woowbs'); ?> </th> <th> <?php esc_html_e('Destination', 'woowbs'); ?> </th> <th> <?php esc_html_e('Weight', 'woowbs'); ?> </th> <th> <?php esc_html_e('Subtotal', 'woowbs'); ?> </th> <th> <?php esc_html_e('Cost', 'woowbs'); ?> </th> <th class="status"> <?php esc_html_e('Active', 'woowbs'); ?> </th> <th> <?php esc_html_e('Actions'); ?> </th> </tr> </thead> <tbody> <?php /** @var WC_Weight_Based_Shipping[] $profiles */ ?> <?php foreach ($profiles as $profile) { ?> <tr <?php echo $profile->profile_id === $current_profile_id ? 'class="wbs-current"' : null; ?> data-settings-url="<?php echo esc_html(WbsRuleUrls::edit($profile)); ?> " > <td class="name"><?php echo esc_html($profile->name); ?> </td> <td class="countries"> <?php if ($profile->availability === 'all') { ?> <?php esc_html_e('Any', 'woowbs'); ?> <?php } else { ?> <?php if ($profile->availability === 'excluding') { ?> <?php esc_html_e('All except', 'woowbs'); ?> <?php } ?> <?php echo esc_html(join(', ', $profile->countries)); ?> <?php } ?> </td> <?php foreach (array($profile->weight, $profile->subtotal) as $range) { ?> <td> <?php echo isset($range->min) || isset($range->max) ? ($range->minInclusive || !isset($range->min) ? '[' : '(') . esc_html(wc_format_localized_decimal((double) $range->min)) . ' – ' . (isset($range->max) ? esc_html(wc_format_localized_decimal($range->max)) : '<span style="font-family:monospace">∞</span>') . ($range->maxInclusive ? ']' : ')') : 'Any'; ?> </td> <?php } ?> <td> <?php echo esc_html($profile->makeCostString()); ?> </td> <td class="status"> <?php if ($profile->enabled == 'yes') { ?> <span class="status-enabled tips" data-tip="<?php esc_html_e('Enabled', 'woowbs'); ?> "><?php esc_html_e('Enabled', 'woowbs'); ?> </span> <?php } else { ?> - <?php } ?> </td> <td class="actions"> <a class="button" href="<?php echo esc_html(WbsRuleUrls::duplicate($profile)); ?> "> <?php esc_html_e('Duplicate', 'woowbs'); ?> </a> <a class="button" href="<?php echo esc_html(WbsRuleUrls::delete($profile)); ?> " onclick="return confirm('<?php esc_html_e('Are you sure you want to delete this rule?', 'woowbs'); ?> ');"> <?php esc_html_e('Delete'); ?> </a> </td> </tr> <?php } ?> </tbody> </table> <script> jQuery((function($) { var $table = $("#woowbs_shipping_methods"); $table.find('tbody').on("sortcreate", function() { $(this).sortable('destroy'); }); $table.find('td').click(function(e) { if (e.target == this) location.href = $(this).parent().data('settingsUrl'); }); })(jQuery)); </script> <!--suppress CssUnusedSymbol --> <style> #woowbs_shipping_methods td { cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #woowbs_shipping_methods .actions { white-space: nowrap; } #woowbs_shipping_methods .countries { max-width: 15em; } #woowbs_shipping_methods .wbs-current td { background-color: #eee; } #woowbs_shipping_methods tr:hover td { background-color: #ddd; } tr.wbs-title th { padding: 2em 0 0 0; } tr.wbs-title h4 { font-size: 1.2em; } .wc-settings-sub-title { padding-top: 2em; } .form-table { border-top: 1px solid #aaa; } tr.wbs-profiles > td { padding: 0; } .wbs-destination label { display: none; } .wbs-destination .forminp { padding-top: 0; } .wbs-destination fieldset { margin-top: -15px !important; } .wbs-subtotal .forminp { padding-bottom: 0} .wbs-subtotal + tr > * { padding-top: 0 } .wbs-subtotal + tr label { display: none; } .wbs-minifield { width: 15.7em; } .wbs-minifield.wc_input_decimal { text-align: right; } .wbs-minifield-container { display: block ! important; } .wbs-minifield-label { display: inline-block; min-width: 3em; } .wbs-range-simple .wbs-minifield-label { min-width: 5em; } .wbs-range-simple .wbs-minifield { min-width: 19.7em; } .wbs-weight-rate .wbs-minifield-label { min-width: 5em; } .wbs-weight-rate .wbs-minifield { width: 17.3em; } .wbs-input-group { display: inline-block; height: 29px; box-sizing: border-box; } .wbs-input-group-addon { display: inline-block; box-sizing: border-box; height: 100%; width: 2.5em; text-align: center; border: 1px solid #ddd; padding: 3px 0; } .wbs-input-group-addon:first-child { border-right: 0; float: left; } .wbs-input-group-addon:last-child { border-left: 0; float: right; } .wbs-input-group input[type="text"] { display: inline-block; height: 100%; box-sizing: border-box; margin: 0; } .wbs-code { font-size: inherit; padding: 0 0.5em; font-family: monospace; } .shippingrows { overflow: hidden; } .shippingrows th, .shippingrows td { width: auto; white-space: nowrap; padding: 1em; } .shippingrows .wc_input_decimal { width: 7em; } .flat_rate .wbs-minifield-container { display: inline !important; margin-left: 1em; } .flat_rate .wbs-minifield-container:first-child { margin-left: 0; } .flat_rate .wbs-minifield-label { display: inline; } .flat_rate .wbs-minifield { width: 6em; } .flat_rate_tpl { display: none; } </style> <?php }
public function _outputSettingsLink($links) { array_unshift($links, '<a href="' . esc_html(WbsRuleUrls::generic()) . '">' . __('Settings', 'woowbs') . '</a>'); return $links; }