Exemple #1
0
 protected function initPluginOptions()
 {
     $this->m_aAllBootstrapLessOptions = HLT_BootstrapCss::getOption(self::$LESS_OPTIONS_DB_KEY);
     if (!empty($this->m_aAllBootstrapLessOptions)) {
         return true;
     }
     //Basically if the array is empty from the WP Options table, create it from scratch.
     $this->m_aAllBootstrapLessOptions = array(array('section_title' => 'Grays', 'section_options' => array(array(self::LessOptionsPrefix . 'black', '', '#000', 'less_color', 'Black', '@black'), array(self::LessOptionsPrefix . 'grayDarker', '', '#222', 'less_color', 'Darker Gray', '@grayDarker'), array(self::LessOptionsPrefix . 'grayDark', '', '#333', 'less_color', 'Dark Gray', '@grayDark'), array(self::LessOptionsPrefix . 'gray', '', '#555', 'less_color', 'Gray', '@gray'), array(self::LessOptionsPrefix . 'grayLight', '', '#999', 'less_color', 'Light Gray', '@grayLight'), array(self::LessOptionsPrefix . 'grayLighter', '', '#eee', 'less_color', 'Lighter Gray', '@grayLighter'), array(self::LessOptionsPrefix . 'white', '', '#fff', 'less_color', 'White', '@white'))), array('section_title' => 'Fonts, Colours & Links', 'section_options' => array(array(self::LessOptionsPrefix . 'bodyBackground', '', '@white', 'less_color', 'Body Background Colour', '@bodyBackground'), array(self::LessOptionsPrefix . 'textColor', '', '@grayDark', 'less_color', 'Text Colour', '@textColor'), array(self::LessOptionsPrefix . 'linkColor', '', '#08c', 'less_color', 'Link Colour', '@linkColor'), array(self::LessOptionsPrefix . 'linkColorHover', '', 'darken(@linkColor, 15%)', 'less_color', 'Link Hover Colour', '@linkColorHover'), array(self::LessOptionsPrefix . 'blue', '', '#049cdb', 'less_color', 'Blue', '@blue'), array(self::LessOptionsPrefix . 'blueDark', '', '#0064cd', 'less_color', 'Dark Blue', '@blueDark'), array(self::LessOptionsPrefix . 'green', '', '#46a546', 'less_color', 'Green', '@green'), array(self::LessOptionsPrefix . 'red', '', '#9d261d', 'less_color', 'Red', '@red'), array(self::LessOptionsPrefix . 'yellow', '', '#ffc40d', 'less_color', 'Yellow', '@yellow'), array(self::LessOptionsPrefix . 'orange', '', '#f89406', 'less_color', 'Orange', '@orange'), array(self::LessOptionsPrefix . 'pink', '', '#c3325f', 'less_color', 'Pink', '@pink'), array(self::LessOptionsPrefix . 'purple', '', '#7a43b6', 'less_color', 'Purple', '@purple'), array(self::LessOptionsPrefix . 'baseFontSize', '', '13px', 'less_size', 'Font Size', '@baseFontSize'), array(self::LessOptionsPrefix . 'baseLineHeight', '', '18px', 'less_size', 'Base Line Height', '@baseLineHeight'), array(self::LessOptionsPrefix . 'baseFontFamily', '', '"Helvetica Neue", Helvetica, Arial, sans-serif', 'less_font', 'Fonts', '@baseFontFamily'), array(self::LessOptionsPrefix . 'altFontFamily', '', 'Georgia, "Times New Roman", Times, serif', 'less_font', 'Alternative Fonts', '@altFontFamily'))), array('section_title' => 'Button Styling', 'section_options' => array(array(self::LessOptionsPrefix . 'btnBackground', '', '@white', 'less_color', 'Background'), array(self::LessOptionsPrefix . 'btnBackgroundHighlight', '', 'darken(@white, 10%)', 'less_color', 'Background Highlight'), array(self::LessOptionsPrefix . 'btnPrimaryBackground', '', '@linkColor', 'less_color', 'Primary Btn Background'), array(self::LessOptionsPrefix . 'btnPrimaryBackgroundHighlight', '', 'spin(@btnPrimaryBackground, 15%)', 'less_color', 'Primary Btn Highlight'), array(self::LessOptionsPrefix . 'btnInfoBackground', '', '#5bc0de', 'less_color', 'Info Btn Background'), array(self::LessOptionsPrefix . 'btnInfoBackgroundHighlight', '', '#2f96b4', 'less_color', 'Info Btn Highlight'), array(self::LessOptionsPrefix . 'btnSuccessBackground', '', '#62c462', 'less_color', 'Success Btn Background'), array(self::LessOptionsPrefix . 'btnSuccessBackgroundHighlight', '', '#51a351', 'less_color', 'Success Btn Highlight'), array(self::LessOptionsPrefix . 'btnWarningBackground', '', 'lighten(@orange, 15%)', 'less_color', 'Warning Btn Background'), array(self::LessOptionsPrefix . 'btnWarningBackgroundHighlight', '', '@orange', 'less_color', 'Warning Btn Highlight'), array(self::LessOptionsPrefix . 'btnDangerBackground', '', '#ee5f5b', 'less_color', 'Danger Btn Background'), array(self::LessOptionsPrefix . 'btnDangerBackgroundHighlight', '', '#bd362f', 'less_color', 'Danger Btn Highlight'), array(self::LessOptionsPrefix . 'btnInverseBackground', '', '@gray', 'less_color', 'Inverse Btn Background'), array(self::LessOptionsPrefix . 'btnInverseBackgroundHighlight', '', '@grayDarker', 'less_color', 'Inverse Btn Highlight'), array(self::LessOptionsPrefix . 'btnBorder', '', 'darken(@white, 20%)', 'less_color', 'Button Border'))), array('section_title' => 'Alerts and Form States', 'section_options' => array(array(self::LessOptionsPrefix . 'warningText', '', '#c09853', 'less_color', 'Warning Text Colour'), array(self::LessOptionsPrefix . 'warningBackground', '', '#fcf8e3', 'less_color', 'Warning Background Colour'), array(self::LessOptionsPrefix . 'warningBorder', '', 'darken(spin(@warningBackground, -10), 3%)', 'less_color', 'Warning Border Colour'), array('spacer'), array(self::LessOptionsPrefix . 'errorText', '', '#b94a48', 'less_color', 'Error Text Colour'), array(self::LessOptionsPrefix . 'errorBackground', '', '#f2dede', 'less_color', 'Error Background Colour'), array(self::LessOptionsPrefix . 'errorBorder', '', 'darken(spin(@errorBackground, -10), 3%)', 'less_color', 'Error Border Colour'), array('spacer'), array(self::LessOptionsPrefix . 'successText', '', '#468847', 'less_color', 'Success Text Colour'), array(self::LessOptionsPrefix . 'successBackground', '', '#dff0d8', 'less_color', 'Success Background Colour'), array(self::LessOptionsPrefix . 'successBorder', '', 'darken(spin(@successBackground, -10), 5%)', 'less_color', 'Success Border Colour'), array('spacer'), array(self::LessOptionsPrefix . 'infoText', '', '#3a87ad', 'less_color', 'Info Text Colour'), array(self::LessOptionsPrefix . 'infoBackground', '', '#d9edf7', 'less_color', 'Info Background Colour'), array(self::LessOptionsPrefix . 'infoBorder', '', 'darken(spin(@infoBackground, -10), 7%)', 'less_color', 'Info Border Colour'), array('spacer'))), array('section_title' => 'The Grid', 'section_options' => array(array(self::LessOptionsPrefix . 'gridColumns', '', '12', 'less_text', 'Grid Columns'), array(self::LessOptionsPrefix . 'gridColumnWidth', '', '60px', 'less_size', 'Grid Column Width'), array(self::LessOptionsPrefix . 'gridGutterWidth', '', '20px', 'less_size', 'Grid Gutter Width'), array(self::LessOptionsPrefix . 'gridRowWidth', '', '(@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1))', 'less_size', 'Grid Row Width'))));
     return true;
 }
Exemple #2
0
 /**
  * Handles the upgrade from version 1 to version 2 of Twitter Bootstrap as well as any other plugin upgrade
  */
 protected function handlePluginUpgrade()
 {
     //current_user_can( 'manage_options' ) ensure only valid users attempt this.
     if (self::getOption('current_plugin_version') !== self::$VERSION && current_user_can('manage_options')) {
         //Manages those users who are coming from a version pre-Twitter 2.0+
         if (self::getOption('upgraded1to2') !== 'Y') {
             if (self::getOption('alerts_js') === 'Y' || self::getOption('tabs_js') === 'Y' || self::getOption('twipsy_js') === 'Y') {
                 self::updateOption('all_js', 'Y');
             }
             self::addOption('upgraded1to2', 'Y');
         }
         //Manages migration to version 2.0.3 where legacy twitter and individual Javascript libraries were removed
         if (self::getOption('alert_js') == 'Y' || self::getOption('button_js') == 'Y' || self::getOption('dropdown_js') == 'Y' || self::getOption('modal_js') == 'Y' || self::getOption('tooltip_js') == 'Y' || self::getOption('popover_js') == 'Y' || self::getOption('scrollspy_js') == 'Y' || self::getOption('tab_js') == 'Y' || self::getOption('transition_js') == 'Y' || self::getOption('collapse_js') == 'Y' || self::getOption('carousel_js') == 'Y' || self::getOption('typeahead_js') == 'Y') {
             self::updateOption('all_js', 'Y');
         }
         //Delete all old plugin options from all previous versions if they exist.
         $m_aAllOldPluginOptions = array('hotlink', 'alert_js', 'button_js', 'dropdown_js', 'modal_js', 'tooltip_js', 'popover_js', 'scrollspy_js', 'tab_js', 'transition_js', 'collapse_js', 'carousel_js', 'typeahead_js', 'alerts_js', 'tabs_js', 'twipsy_js');
         foreach ($m_aAllOldPluginOptions as $sOldOptions) {
             self::deleteOption($sOldOptions);
         }
         //Recompile LESS CSS if applicable and delete all old WP Options values from DB
         if (self::getOption('use_compiled_css') == 'Y') {
             $oBoostrapLess = new HLT_BootstrapLess();
             //Get the array of plugin options
             $aBootstrapOptions = $this->getOption(HLT_BootstrapLess::$LESS_OPTIONS_DB_KEY);
             if (empty($aBootstrapOptions)) {
                 //pre-2.0.4.2 version of the plugin
                 $aBootstrapOptions = $oBoostrapLess->getAllBootstrapLessOptions();
                 foreach ($aBootstrapOptions as &$aLessSection) {
                     foreach ($aLessSection['section_options'] as &$aOptionParams) {
                         list($sOptionKey, $sOptionSaved, $sOptionDefault, $sOptionType, $sOptionHumanName) = $aOptionParams;
                         if ($sOptionKey != 'spacer') {
                             //FIX DEBUG: http://wordpress.org/support/topic/plugin-wordpress-twitter-bootstrap-css-noticeswarningsdb-option-usage
                             $sCurrentOptionVal = HLT_BootstrapCss::getOption($sOptionKey);
                             HLT_BootstrapCss::deleteOption($sOptionKey);
                             $aOptionParams[1] = $sCurrentOptionVal == '' ? $sOptionDefault : $sCurrentOptionVal;
                         }
                     }
                     //foreach $aOptionParams
                 }
                 //foreach $aLessSection
                 $this->updateOption(HLT_BootstrapLess::$LESS_OPTIONS_DB_KEY, $aBootstrapOptions);
             }
             if ($oBoostrapLess->reWriteVariablesLess(self::$BOOSTRAP_DIR)) {
                 $oBoostrapLess->compileAllBootstrapLess(self::$BOOSTRAP_DIR);
             }
         }
         //if: use_compiled_css == 'Y'
         //Set the flag so that this update handler isn't run again for this version.
         self::updateOption('current_plugin_version', self::$VERSION);
     }
     //if
     //Someone clicked the button to acknowledge the update
     if (isset($_POST['hlt_hide_update_notice']) && isset($_POST['hlt_user_id'])) {
         $result = update_user_meta($_POST['hlt_user_id'], 'hlt_bootstrapcss_current_version', self::$VERSION);
         header("Location: admin.php?page=" . $this->getFullParentMenuId());
     }
 }