コード例 #1
0
 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);
 }
コード例 #2
0
    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>
                    ';
            }
        }
    }
コード例 #3
0
 private function refresh()
 {
     echo '<script>location.href = ', json_encode(WbsRuleUrls::generic()), ';</script>';
     die;
 }
コード例 #4
0
 public function _outputSettingsLink($links)
 {
     array_unshift($links, '<a href="' . esc_html(WbsRuleUrls::generic()) . '">' . __('Settings', 'woowbs') . '</a>');
     return $links;
 }