예제 #1
0
 function renderSubmitButtons()
 {
     $update = new EzSubmit('saveChanges');
     $update->desc = __('Save Changes', 'easy-common');
     $update->title = __('Save the changes as specified above', 'easy-common');
     $update->tipTitle = $update->desc;
     $reset = new EzSubmit('resetOptions');
     $reset->desc = __('Reset Options', 'easy-common');
     $reset->title = __('This <b>Reset Options</b> button discards all your changes and loads the default options. This is your only warning!', 'easy-common');
     $reset->tipWarning = true;
     $cleanDB = new EzSubmit('cleanDB');
     $cleanDB->desc = __('Clean Database', 'easy-common');
     $cleanDB->title = __('The <b>Database Cleanup</b> button discards all your AdSense settings you have saved so far for <b>all</b> the themes, including the current one. Use it only if you know that you will not be using these themes. Please be careful with all database operations -- keep a backup.', 'easy-common');
     $cleanDB->tipWarning = true;
     $uninstall = new EzSubmit('uninstall');
     $uninstall->desc = __('Uninstall', 'easy-common');
     $uninstall->title = __('The <b>Uninstall</b> button really kills %s after cleaning up all the options it wrote in your database. This is your only warning! Please be careful with all database operations -- keep a backup.', 'easy-common');
     $uninstall->tipWarning = true;
     $update->render();
     $reset->render();
     $cleanDB->render();
     $uninstall->render();
 }
        function printAdminPage()
        {
            // if translating, print translation interface
            if ($this->ezTran->printAdminPage()) {
                return;
            }
            require $this->plgDir . '/myPlugins.php';
            $slug = $this->slug;
            $plg = $this->myPlugins[$slug];
            $plgURL = $this->plgURL;
            require_once $this->plgDir . '/EzAdmin.php';
            $this->ezAdmin = new EzAdmin($plg, $slug, $plgURL);
            $this->ezAdmin->plgFile = __FILE__;
            if ($this->options['kill_author']) {
                $this->ezAdmin->killAuthor = true;
            }
            $this->ezAdmin->domain = $this->domain;
            $ez = $this->ezAdmin;
            $mThemeName = get_option('stylesheet');
            // grab the theme stylesheet and print it here
            $stylefile = get_theme_root() . '/' . $mThemeName . '/style.css';
            $stylecontent = file_get_contents($stylefile);
            $colors0 = $this->getColors($stylecontent);
            // if the theme colors haven't changed, use the new colors from DB
            // else init them to the original colors
            if ($colors0 == $this->options['oldColors']) {
                $colors1 = $this->options['newColors'];
            } else {
                $colors1 = $colors0;
            }
            if (isset($_POST['saveChanges']) || isset($_POST['cleanDB'])) {
                // loop over the new color fields to get colors1
                foreach ($colors0 as $key => $val) {
                    $name = 'in_' . substr($val, -6);
                    if (isset($_POST[$name])) {
                        $colors1[$key] = $_POST[$name];
                    } else {
                        $colors1[$key] = '#FFFFFF';
                    }
                }
                if (isset($_POST['kill_invites'])) {
                    $this->options['kill_invites'] = $_POST['kill_invites'];
                }
                if (isset($_POST['kill_rating'])) {
                    $this->options['kill_rating'] = $_POST['kill_rating'];
                }
                // need to replace in two steps, just in case colors0 and colors1 have overlaps
                $tmpcols = $this->mapFunc($colors0, 'tmpColor');
                // generate the new style
                $func = 'str_ireplace';
                $styletmp = $func($colors0, $tmpcols, $stylecontent);
                $stylestr = $func($tmpcols, $colors1, $styletmp);
                $this->options['oldColors'] = $colors0;
                $this->options['newColors'] = $colors1;
                $this->options['fullCSS'] = $stylestr;
                $trimstr = $this->trimCSS($stylestr);
                $this->options['trimmedCSS'] = $trimstr;
                $this->mkEzOptions();
                $this->setOptionValues();
                foreach ($this->ezOptions as $k => $o) {
                    if (isset($this->options[$k])) {
                        $this->options[$k] = $o->get();
                    } else {
                        if (WP_DEBUG) {
                            echo "<div class='error'>Warning: <code>option[{$k}]</code> is not defined, but <code>ezOption[{$k}]</code> exists!</div>";
                        }
                    }
                }
                update_option($this->optionName, $this->options);
                if (isset($_POST['cleanDB'])) {
                    $this->cleanDB('themeTweaker');
                }
            }
            $this->mkEzOptions();
            $this->setOptionValues();
            echo '<script type="text/javascript" src="' . $this->plgURL . '/jscolor/jscolor.js"></script>';
            echo '<script type="text/javascript" src="' . $this->plgURL . '/wz_tooltip.js"></script>';
            ?>

      <div class="wrap" style="width:1000px">
        <h2>Theme Tweaker <a href="http://validator.w3.org/" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid HTML5" title="Theme Tweaker Admin Page is certified Valid HTML5" height="31" onmouseover="Tip('Theme Tweaker Admin Page is certified Valid HTML5, with no errors in the HTML code generated by the plugin.')" onmouseout="UnTip()" width="88" class="alignright"/></a></h2>

        <div id="status" class="updated"><?php 
            if (isset($_POST['saveChanges'])) {
                echo $_SESSION['statUpdate'];
            }
            if (isset($_POST['cleanDB'])) {
                echo $_SESSION['statClean'];
            }
            ?>
        </div>
          <?php 
            $helpTags = array();
            $o = new EzHelpTag('help0');
            $o->title = __('Click for help', 'theme-tweaker');
            $o->tipTitle = __('How to Tweak Your Theme', 'theme-tweaker');
            $o->desc = __('Usage: How to tweak your theme colors.', 'theme-tweaker');
            $helpTags[] = $o;
            $help0 = array();
            $help0[] = sprintf(__('The color scheme of your current theme "%s" is shown in the table below as the first column under "Old Colors"', 'theme-tweaker'), $mThemeName);
            $help0[] = __('The new color scheme is in the second column under "Tweaked Colors (Click to modify)." Click on the new colors to modify them. You will get a color picker, or you can type in the new color code as #RRGGBB.', 'theme-tweaker');
            $help0[] = __('Launch the new color scheme in the "preview mode" by checking the preview box. (Preview means only admins can see the changes.)', 'theme-tweaker');
            $help0[] = __('Or choose to "Activate" the new scheme (for everybody) by checking that box.', 'theme-tweaker');
            $help0[] = __('Once ready, click on the "Save Changes" button to save the changes. Note that you will see the changes (in preview or activate mode) only after saving.', 'theme-tweaker');
            $help0[] = __('<b>Theme Tweaker</b> will remember your saved color schemes for any number of themes.', 'theme-tweaker');
            $o = new EzHelpTag('help1');
            $o->title = __('Click for help', 'theme-tweaker');
            $o->tipTitle = __('How to Save Stylefiles', 'theme-tweaker');
            $o->desc = __('Generating theme files and child themes.', 'theme-tweaker');
            $helpTags[] = $o;
            $help1 = array();
            $help1[] = __('You can download the tweaked theme style sheet by clicking on the "Download Stylesheet" button. It saves the changes and then downloads a style.css file that you can upload to your blog server theme directory if you want to make your changes permanent.', 'theme-tweaker');
            $help1[] = __('Or, you can click on the "Generate Child Theme" button to download a child theme stylesheet (style.css) with the colors as specified above to your local computer, which you can upload to your blog server to make them permanent. Child theme is a better way to go, because it allows you to keep the original theme files untouched.', 'theme-tweaker');
            ?>
        <h3><?php 
            _e('Instructions', 'theme-tweaker');
            ?>
</h3>
        <table>
          <tr style="vertical-align:top">
            <td style="width:400px">
              <ul style="padding-left:10px;list-style-type:circle; list-style-position:inside;" >
      <?php 
            foreach ($helpTags as $help) {
                echo "<li>";
                $help->render();
                echo "</li>\n";
            }
            ?>
              </ul>
              <div id="help0" style="display:none;">
                <ul style="padding-left:10px;list-style-type:circle; list-style-position:inside;" >
      <?php 
            foreach ($help0 as $h) {
                echo "<li>{$h}</li>";
            }
            ?>
                </ul>
              </div>
              <div id="help1" style="display:none;">
                <ul style="padding-left:10px;list-style-type:circle; list-style-position:inside;" >
      <?php 
            foreach ($help1 as $h) {
                echo "<li>{$h}</li>";
            }
            ?>
                </ul>
              </div>
            </td>
      <?php 
            include $this->plgDir . '/head-text.php';
            ?>
            <td>
            </td>
          </tr>
        </table>

        <form method="post" action="#">
      <?php 
            $ez->renderNags($this->options);
            ?>
          <h3>Tweak the Colors Found in "<?php 
            echo $mThemeName;
            ?>
"</h3>
          <table>
            <tr style="vertical-align:top">
              <td>
                <table>
                  <tr style="vertical-align:middle;text-align:center;">
                    <td style="width:350px">
      <?php 
            echo $this->makeTable($colors0, $colors1);
            ?>
                    </td>
                    <td style="width:350px">
                      <?php 
            echo $this->makeButtons($colors0, $colors1);
            ?>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
          <h3>Options for the Tweaked "<?php 
            echo $mThemeName;
            ?>
"</h3>
      <?php 
            foreach ($this->ezOptions as $o) {
                $o->render();
            }
            // make the strings to save to file, just in case the user wants them
            $_SESSION['strCSS'] = $this->makeString('CSS');
            // status messages
            $statUpdate = htmlspecialchars(__('Updated Settings', "theme-tweaker"));
            $_SESSION['statUpdate'] = $statUpdate;
            $statClean = htmlspecialchars(__("Database has been cleaned. All your options for this plugin (for all themes) have been removed.", "theme-tweaker"));
            $_SESSION['statClean'] = $statClean;
            ?>
          <div class="submit">
          <?php 
            echo "<h4>" . __('Save your color tweaks and options?', 'theme-tweaker') . "</h4>";
            $preview = new EzSubmit('previewNow');
            $preview->desc = __('Preview', 'theme-tweaker');
            $preview->title = __('Check the preview option, save your options and <em>then</em> click here to see your color scheme', 'theme-tweaker');
            $siteurl = get_option('siteurl');
            $preview->onclick = "window.open('{$siteurl}', 'previewNow', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + 0.9 * screen.width + 'px,height=' + 0.8 * screen.height + 'px,left=' + 0.05 * screen.width + ',top=' + 0.05 * screen.width).focus();";
            $preview->tipTitle = $preview->desc;
            $update = new EzSubmit('saveChanges');
            $update->desc = __('Save Changes', 'theme-tweaker');
            $update->title = __('Save the changes as specified above', 'theme-tweaker');
            $update->tipTitle = $update->desc;
            $cleanDB = new EzSubmit('cleanDB');
            $cleanDB->desc = __('Clean Database', 'theme-tweaker');
            $cleanDB->title = __('The <b>Database Cleanup</b> button discards all your AdSense settings you have saved so far for <b>all</b> the themes, including the current one. Use it only if you know that you will not be using these themes. Please be careful with all database operations -- keep a backup.', 'theme-tweaker');
            $cleanDB->tipWarning = true;
            $preview->render();
            $update->render();
            $cleanDB->render();
            ?>
          </div>
        </form>

      <?php 
            $ez->renderWhyPro();
            ?>

        <form method='post'>
        <?php 
            $this->ezTran->renderTranslator();
            ?>
        </form><br />
          <?php 
            $ez->renderSupport();
            include $this->plgDir . '/tail-text.php';
            ?>
        <h3>Credits</h3>
        <table style="width:100%">
          <tr><td>
              <ul style="padding-left:10px;list-style-type:circle; list-style-position:inside;" >
                <li>
      <?php 
            printf(__('%s uses the Javascript/DHTML color picker by %s', 'easy-common'), '<b>Theme Tweaker' . $this->strPro . '</b>', '<a href="http://jscolor.com" target="_blank" title="Javascript color picker"> JScolor</a>.');
            ?>
                </li>
                <li>
                  <?php 
            printf(__('%s uses the excellent Javascript/DHTML tooltips by %s', 'easy-common'), '<b>Theme Tweaker' . $this->strPro . '</b>', '<a href="http://www.walterzorn.com" target="_blank" title="Javascript, DTML Tooltips"> Walter Zorn</a>.');
            ?>
                </li>
              </ul>
            </td>
          </tr>
        </table>
      </div>
      <?php 
        }