public static function capture_crayons($wp_id, $wp_content, $extra_settings = array(), $args = array())
 {
     extract($args);
     CrayonUtil::set_var($callback, NULL);
     CrayonUtil::set_var($callback_extra_args, NULL);
     CrayonUtil::set_var($ignore, TRUE);
     CrayonUtil::set_var($preserve_atts, FALSE);
     CrayonUtil::set_var($flags, NULL);
     CrayonUtil::set_var($skip_setting_check, FALSE);
     CrayonUtil::set_var($just_check, FALSE);
     // Will contain captured crayons and altered $wp_content
     $capture = array('capture' => array(), 'content' => $wp_content, 'has_captured' => FALSE);
     // Do not apply Crayon for posts older than a certain date.
     $disable_date = trim(CrayonGlobalSettings::val(CrayonSettings::DISABLE_DATE));
     if ($disable_date && get_post_time('U', true, $wp_id) <= strtotime($disable_date)) {
         return $capture;
     }
     // Flags for which Crayons to convert
     $in_flag = self::in_flag($flags);
     CrayonLog::debug('capture for id ' . $wp_id . ' len ' . strlen($wp_content));
     // Convert <pre> tags to crayon tags, if needed
     if ((CrayonGlobalSettings::val(CrayonSettings::CAPTURE_PRE) || $skip_setting_check) && $in_flag[CrayonSettings::CAPTURE_PRE]) {
         // XXX This will fail if <pre></pre> is used inside another <pre></pre>
         $wp_content = preg_replace_callback('#(?<!\\$)<\\s*pre(?=(?:([^>]*)\\bclass\\s*=\\s*(["\'])(.*?)\\2([^>]*))?)([^>]*)>(.*?)<\\s*/\\s*pre\\s*>#msi', 'CrayonWP::pre_tag', $wp_content);
     }
     // Convert mini [php][/php] tags to crayon tags, if needed
     if ((CrayonGlobalSettings::val(CrayonSettings::CAPTURE_MINI_TAG) || $skip_setting_check) && $in_flag[CrayonSettings::CAPTURE_MINI_TAG]) {
         $wp_content = preg_replace('#(?<!\\$)\\[\\s*(' . self::$alias_regex . ')\\b([^\\]]*)\\](.*?)\\[\\s*/\\s*(?:\\1)\\s*\\](?!\\$)#msi', '[crayon lang="\\1" \\2]\\3[/crayon]', $wp_content);
         $wp_content = preg_replace('#(?<!\\$)\\[\\s*(' . self::$alias_regex . ')\\b([^\\]]*)/\\s*\\](?!\\$)#msi', '[crayon lang="\\1" \\2 /]', $wp_content);
     }
     // Convert <code> to inline tags
     if (CrayonGlobalSettings::val(CrayonSettings::CODE_TAG_CAPTURE)) {
         $inline = CrayonGlobalSettings::val(CrayonSettings::CODE_TAG_CAPTURE_TYPE) === 0;
         $inline_setting = $inline ? 'inline="true"' : '';
         $wp_content = preg_replace('#<(\\s*code\\b)([^>]*)>(.*?)</\\1[^>]*>#msi', '[crayon ' . $inline_setting . ' \\2]\\3[/crayon]', $wp_content);
     }
     if ((CrayonGlobalSettings::val(CrayonSettings::INLINE_TAG) || $skip_setting_check) && $in_flag[CrayonSettings::INLINE_TAG]) {
         if (CrayonGlobalSettings::val(CrayonSettings::INLINE_TAG_CAPTURE)) {
             // Convert inline {php}{/php} tags to crayon tags, if needed
             $wp_content = preg_replace('#(?<!\\$)\\{\\s*(' . self::$alias_regex . ')\\b([^\\}]*)\\}(.*?)\\{/(?:\\1)\\}(?!\\$)#msi', '[crayon lang="\\1" inline="true" \\2]\\3[/crayon]', $wp_content);
         }
         // Convert <span class="crayon-inline"> tags to inline crayon tags
         $wp_content = preg_replace_callback('#(?<!\\$)<\\s*span([^>]*)\\bclass\\s*=\\s*(["\'])(.*?)\\2([^>]*)>(.*?)<\\s*/\\s*span\\s*>#msi', 'CrayonWP::span_tag', $wp_content);
     }
     // Convert [plain] tags into <pre><code></code></pre>, if needed
     if ((CrayonGlobalSettings::val(CrayonSettings::PLAIN_TAG) || $skip_setting_check) && $in_flag[CrayonSettings::PLAIN_TAG]) {
         $wp_content = preg_replace_callback('#(?<!\\$)\\[\\s*plain\\s*\\](.*?)\\[\\s*/\\s*plain\\s*\\]#msi', 'CrayonFormatter::plain_code', $wp_content);
     }
     // Add IDs to the Crayons
     CrayonLog::debug('capture adding id ' . $wp_id . ' , now has len ' . strlen($wp_content));
     $wp_content = preg_replace_callback(self::REGEX_ID, 'CrayonWP::add_crayon_id', $wp_content);
     CrayonLog::debug('capture added id ' . $wp_id . ' : ' . strlen($wp_content));
     // Only include if a post exists with Crayon tag
     preg_match_all(self::regex(), $wp_content, $matches);
     $capture['has_captured'] = count($matches[0]) != 0;
     if ($just_check) {
         // Backticks are matched after other tags, so they need to be captured here.
         $result = self::replace_backquotes($wp_content);
         $wp_content = $result['content'];
         $capture['has_captured'] = $capture['has_captured'] || $result['changed'];
         $capture['content'] = $wp_content;
         return $capture;
     }
     CrayonLog::debug('capture ignore for id ' . $wp_id . ' : ' . strlen($capture['content']) . ' vs ' . strlen($wp_content));
     if ($capture['has_captured']) {
         // Crayons found! Load settings first to ensure global settings loaded
         CrayonSettingsWP::load_settings();
         CrayonLog::debug('CAPTURED FOR ID ' . $wp_id);
         $full_matches = $matches[0];
         $closed_ids = $matches[1];
         $closed_atts = $matches[2];
         $open_ids = $matches[3];
         $open_atts = $matches[4];
         $contents = $matches[5];
         // Make sure we enqueue the styles/scripts
         $enqueue = TRUE;
         for ($i = 0; $i < count($full_matches); $i++) {
             // Get attributes
             if (!empty($closed_atts[$i])) {
                 $atts = $closed_atts[$i];
             } else {
                 if (!empty($open_atts[$i])) {
                     $atts = $open_atts[$i];
                 } else {
                     $atts = '';
                 }
             }
             // Capture attributes
             preg_match_all('#([^="\'\\s]+)[\\t ]*=[\\t ]*("|\')(.*?)\\2#', $atts, $att_matches);
             // Add extra attributes
             $atts_array = $extra_settings;
             if (count($att_matches[0]) != 0) {
                 for ($j = 0; $j < count($att_matches[1]); $j++) {
                     $atts_array[trim(strtolower($att_matches[1][$j]))] = trim($att_matches[3][$j]);
                 }
             }
             if (isset($atts_array[CrayonSettings::IGNORE]) && $atts_array[CrayonSettings::IGNORE]) {
                 // TODO(aramk) Revert to the original content.
                 continue;
             }
             // Capture theme
             $theme_id = array_key_exists(CrayonSettings::THEME, $atts_array) ? $atts_array[CrayonSettings::THEME] : '';
             $theme = CrayonResources::themes()->get($theme_id);
             // If theme not found, use fallbacks
             if (!$theme) {
                 // Given theme is invalid, try global setting
                 $theme_id = CrayonGlobalSettings::val(CrayonSettings::THEME);
                 $theme = CrayonResources::themes()->get($theme_id);
                 if (!$theme) {
                     // Global setting is invalid, fall back to default
                     $theme = CrayonResources::themes()->get_default();
                     $theme_id = CrayonThemes::DEFAULT_THEME;
                 }
             }
             // If theme is now valid, change the array
             if ($theme) {
                 if (!$preserve_atts || isset($atts_array[CrayonSettings::THEME])) {
                     $atts_array[CrayonSettings::THEME] = $theme_id;
                 }
                 $theme->used(TRUE);
             }
             // Capture font
             $font_id = array_key_exists(CrayonSettings::FONT, $atts_array) ? $atts_array[CrayonSettings::FONT] : '';
             $font = CrayonResources::fonts()->get($font_id);
             // If font not found, use fallbacks
             if (!$font) {
                 // Given font is invalid, try global setting
                 $font_id = CrayonGlobalSettings::val(CrayonSettings::FONT);
                 $font = CrayonResources::fonts()->get($font_id);
                 if (!$font) {
                     // Global setting is invalid, fall back to default
                     $font = CrayonResources::fonts()->get_default();
                     $font_id = CrayonFonts::DEFAULT_FONT;
                 }
             }
             // If font is now valid, change the array
             if ($font) {
                 if (!$preserve_atts || isset($atts_array[CrayonSettings::FONT])) {
                     $atts_array[CrayonSettings::FONT] = $font_id;
                 }
                 $font->used(TRUE);
             }
             // Add array of atts and content to post queue with key as post ID
             // XXX If at this point no ID is added we have failed!
             $id = !empty($open_ids[$i]) ? $open_ids[$i] : $closed_ids[$i];
             //if ($ignore) {
             $code = self::crayon_remove_ignore($contents[$i]);
             //}
             $c = array('post_id' => $wp_id, 'atts' => $atts_array, 'code' => $code);
             $capture['capture'][$id] = $c;
             CrayonLog::debug('capture finished for post id ' . $wp_id . ' crayon-id ' . $id . ' atts: ' . count($atts_array) . ' code: ' . strlen($code));
             $is_inline = isset($atts_array['inline']) && CrayonUtil::str_to_bool($atts_array['inline'], FALSE) ? '-i' : '';
             if ($callback === NULL) {
                 $wp_content = str_replace($full_matches[$i], '[crayon-' . $id . $is_inline . '/]', $wp_content);
             } else {
                 $wp_content = call_user_func($callback, $c, $full_matches[$i], $id, $is_inline, $wp_content, $callback_extra_args);
             }
         }
     }
     if ($ignore) {
         // We need to escape ignored Crayons, since they won't be captured
         // XXX Do this after replacing the Crayon with the shorter ID tag, otherwise $full_matches will be different from $wp_content
         $wp_content = self::crayon_remove_ignore($wp_content);
     }
     $result = self::replace_backquotes($wp_content);
     $wp_content = $result['content'];
     $capture['content'] = $wp_content;
     return $capture;
 }
 function is_inline($inline = NULL)
 {
     if ($inline === NULL) {
         return $this->is_inline;
     } else {
         $inline = CrayonUtil::str_to_bool($inline, FALSE);
         $this->is_inline = $inline;
     }
 }
<?php

$crayon_root_theme_editor = dirname(dirname(dirname(__FILE__)));
require_once $crayon_root_theme_editor . '/crayon_wp.class.php';
require_once CrayonWP::wp_load_path();
$theme = CrayonResources::themes()->get_default();
$editing = false;
if (isset($_GET['curr_theme'])) {
    $theme = CrayonResources::themes()->get($_GET['curr_theme']);
}
if (isset($_GET['editing'])) {
    $editing = CrayonUtil::str_to_bool($_GET['editing'], FALSE);
}
// var_dump($_GET);
// var_dump($theme);
// var_dump($editing);
?>

<div id="icon-options-general" class="icon32"><br>
</div>
<h2>Crayon Syntax Highlighter <?php 
crayon_e('Theme Editor');
?>
</h2>

<h3>
<?php 
if ($editing) {
    echo sprintf(crayon__('Editing "%s" Theme'), $theme->name());
} else {
    echo sprintf(crayon__('Creating Theme From "%s"'), $theme->name());
 public static function smart_settings($settings)
 {
     if (!is_array($settings)) {
         return FALSE;
     }
     // If a setting is given, it is automatically enabled
     foreach ($settings as $name => $value) {
         if (($setting = CrayonGlobalSettings::get($name)) !== FALSE && is_bool($setting->def())) {
             $value = CrayonUtil::str_to_bool($value);
         }
         if ($name == 'min-height' || $name == 'max-height' || $name == 'height') {
             self::smart_hw($name, CrayonSettings::HEIGHT_SET, CrayonSettings::HEIGHT_MODE, CrayonSettings::HEIGHT_UNIT, $settings);
         } else {
             if ($name == 'min-width' || $name == 'max-width' || $name == 'width') {
                 self::smart_hw($name, CrayonSettings::WIDTH_SET, CrayonSettings::WIDTH_MODE, CrayonSettings::WIDTH_UNIT, $settings);
             } else {
                 if ($name == CrayonSettings::FONT_SIZE) {
                     $settings[CrayonSettings::FONT_SIZE_ENABLE] = TRUE;
                 } else {
                     if ($name == CrayonSettings::TOP_MARGIN) {
                         $settings[CrayonSettings::TOP_SET] = TRUE;
                     } else {
                         if ($name == CrayonSettings::LEFT_MARGIN) {
                             $settings[CrayonSettings::LEFT_SET] = TRUE;
                         } else {
                             if ($name == CrayonSettings::BOTTOM_MARGIN) {
                                 $settings[CrayonSettings::BOTTOM_SET] = TRUE;
                             } else {
                                 if ($name == CrayonSettings::RIGHT_MARGIN) {
                                     $settings[CrayonSettings::RIGHT_SET] = TRUE;
                                 } else {
                                     if ($name == CrayonSettings::ERROR_MSG) {
                                         $settings[CrayonSettings::ERROR_MSG_SHOW] = TRUE;
                                     } else {
                                         if ($name == CrayonSettings::H_ALIGN) {
                                             $settings[CrayonSettings::FLOAT_ENABLE] = TRUE;
                                             $value = CrayonUtil::tlower($value);
                                             $values = array('none' => 0, 'left' => 1, 'center' => 2, 'right' => 3);
                                             if (array_key_exists($value, $values)) {
                                                 $settings[CrayonSettings::H_ALIGN] = $values[$value];
                                             }
                                         } else {
                                             if ($name == CrayonSettings::SHOW_LANG) {
                                                 $value = CrayonUtil::tlower($value);
                                                 $values = array('found' => 0, 'always' => 1, 'true' => 1, 'never' => 2, 'false' => 2);
                                                 if (array_key_exists($value, $values)) {
                                                     $settings[CrayonSettings::SHOW_LANG] = $values[$value];
                                                 }
                                             } else {
                                                 if ($name == CrayonSettings::TOOLBAR) {
                                                     if (CrayonUtil::tlower($value) == 'always') {
                                                         $settings[CrayonSettings::TOOLBAR] = 1;
                                                     } else {
                                                         if (CrayonUtil::str_to_bool($value) === FALSE) {
                                                             $settings[CrayonSettings::TOOLBAR] = 2;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $settings;
 }
示例#5
0
    public static function content()
    {
        self::initSettings();
        $theme = CrayonResources::themes()->get_default();
        $editing = false;
        if (isset($_GET['curr_theme'])) {
            $currTheme = CrayonResources::themes()->get($_GET['curr_theme']);
            if ($currTheme) {
                $theme = $currTheme;
            }
        }
        if (isset($_GET['editing'])) {
            $editing = CrayonUtil::str_to_bool($_GET['editing'], FALSE);
        }
        $tInformation = crayon__("Information");
        $tHighlighting = crayon__("Highlighting");
        $tFrame = crayon__("Frame");
        $tLines = crayon__("Lines");
        $tNumbers = crayon__("Line Numbers");
        $tToolbar = crayon__("Toolbar");
        $tBackground = crayon__("Background");
        $tText = crayon__("Text");
        $tBorder = crayon__("Border");
        $tTopBorder = crayon__("Top Border");
        $tBottomBorder = crayon__("Bottom Border");
        $tBorderRight = crayon__("Right Border");
        $tHover = crayon__("Hover");
        $tActive = crayon__("Active");
        $tPressed = crayon__("Pressed");
        $tHoverPressed = crayon__("Pressed & Hover");
        $tActivePressed = crayon__("Pressed & Active");
        $tTitle = crayon__("Title");
        $tButtons = crayon__("Buttons");
        $tNormal = crayon__("Normal");
        $tInline = crayon__("Inline");
        $tStriped = crayon__("Striped");
        $tMarked = crayon__("Marked");
        $tStripedMarked = crayon__("Striped & Marked");
        $tLanguage = crayon__("Language");
        $top = '.crayon-top';
        $bottom = '.crayon-bottom';
        $hover = ':hover';
        $active = ':active';
        $pressed = '.crayon-pressed';
        ?>

    <div
            id="icon-options-general" class="icon32"></div>
    <h2>
        Crayon Syntax Highlighter
        <?php 
        crayon_e('Theme Editor');
        ?>
    </h2>

    <h3 id="<?php 
        echo self::$settings['prefix'];
        ?>
-name">
        <?php 
        //			if ($editing) {
        //				echo sprintf(crayon__('Editing "%s" Theme'), $theme->name());
        //			} else {
        //				echo sprintf(crayon__('Creating Theme From "%s"'), $theme->name());
        //			}
        ?>
    </h3>
    <div id="<?php 
        echo self::$settings['prefix'];
        ?>
-info"></div>

    <p>
        <a id="crayon-editor-back" class="button-primary"><?php 
        crayon_e("Back To Settings");
        ?>
</a>
        <a id="crayon-editor-save" class="button-primary"><?php 
        crayon_e("Save");
        ?>
</a>
        <span id="crayon-editor-status"></span>
    </p>

    <?php 
        //crayon_e('Use the Sidebar on the right to change the Theme of the Preview window.')
        ?>

    <div id="crayon-editor-top-controls"></div>

    <table id="crayon-editor-table" style="width: 100%;" cellspacing="5"
           cellpadding="0">
        <tr>
            <td id="crayon-editor-preview-wrapper">
                <div id="crayon-editor-preview"></div>
            </td>
            <div id="crayon-editor-preview-css"></div>
            <td id="crayon-editor-control-wrapper">
                <div id="crayon-editor-controls">
                    <ul>
                        <li title="<?php 
        echo $tInformation;
        ?>
"><a class="crayon-tab-information" href="#tabs-1"></a></li>
                        <li title="<?php 
        echo $tHighlighting;
        ?>
"><a class="crayon-tab-highlighting" href="#tabs-2"></a></li>
                        <li title="<?php 
        echo $tFrame;
        ?>
"><a class="crayon-tab-frame" href="#tabs-3"></a></li>
                        <li title="<?php 
        echo $tLines;
        ?>
"><a class="crayon-tab-lines" href="#tabs-4"></a></li>
                        <li title="<?php 
        echo $tNumbers;
        ?>
"><a class="crayon-tab-numbers" href="#tabs-5"></a></li>
                        <li title="<?php 
        echo $tToolbar;
        ?>
"><a class="crayon-tab-toolbar" href="#tabs-6"></a></li>
                    </ul>
                    <div id="tabs-1">
                        <?php 
        self::createAttributesForm(array(new CrayonHTMLTitle($tInformation)));
        ?>
                        <div id="tabs-1-contents"></div>
                        <!-- Auto-filled by theme_editor.js -->
                    </div>
                    <div id="tabs-2">
                        <?php 
        $highlight = ' .crayon-pre';
        $elems = array('c' => crayon__("Comment"), 's' => crayon__("String"), 'p' => crayon__("Preprocessor"), 'ta' => crayon__("Tag"), 'k' => crayon__("Keyword"), 'st' => crayon__("Statement"), 'r' => crayon__("Reserved"), 't' => crayon__("Type"), 'm' => crayon__("Modifier"), 'i' => crayon__("Identifier"), 'e' => crayon__("Entity"), 'v' => crayon__("Variable"), 'cn' => crayon__("Constant"), 'o' => crayon__("Operator"), 'sy' => crayon__("Symbol"), 'n' => crayon__("Notation"), 'f' => crayon__("Faded"), 'h' => crayon__("HTML"), '' => crayon__("Unhighlighted"));
        $atts = array(new CrayonHTMLTitle($tHighlighting));
        foreach ($elems as $class => $name) {
            $fullClass = $class != '' ? $highlight . ' .crayon-' . $class : $highlight;
            $atts[] = array($name, self::createAttribute($fullClass, 'color'), self::createAttribute($fullClass, 'font-weight'), self::createAttribute($fullClass, 'font-style'), self::createAttribute($fullClass, 'text-decoration'));
        }
        self::createAttributesForm($atts);
        ?>
                    </div>
                    <div id="tabs-3">
                        <?php 
        $inline = '-inline';
        self::createAttributesForm(array(new CrayonHTMLTitle($tFrame), new CrayonHTMLSeparator($tNormal), array($tBorder, self::createAttribute('', 'border-width'), self::createAttribute('', 'border-color'), self::createAttribute('', 'border-style')), new CrayonHTMLSeparator($tInline), self::createAttribute($inline, 'background', $tBackground), array($tBorder, self::createAttribute($inline, 'border-width'), self::createAttribute($inline, 'border-color'), self::createAttribute($inline, 'border-style'))));
        ?>
                    </div>
                    <div id="tabs-4">
                        <?php 
        $stripedLine = ' .crayon-striped-line';
        $markedLine = ' .crayon-marked-line';
        $stripedMarkedLine = ' .crayon-marked-line.crayon-striped-line';
        self::createAttributesForm(array(new CrayonHTMLTitle($tLines), new CrayonHTMLSeparator($tNormal), self::createAttribute('', 'background', $tBackground), new CrayonHTMLSeparator($tStriped), self::createAttribute($stripedLine, 'background', $tBackground), new CrayonHTMLSeparator($tMarked), self::createAttribute($markedLine, 'background', $tBackground), array($tBorder, self::createAttribute($markedLine, 'border-width'), self::createAttribute($markedLine, 'border-color'), self::createAttribute($markedLine, 'border-style')), self::createAttribute($markedLine . $top, 'border-top-style', $tTopBorder), self::createAttribute($markedLine . $bottom, 'border-bottom-style', $tBottomBorder), new CrayonHTMLSeparator($tStripedMarked), self::createAttribute($stripedMarkedLine, 'background', $tBackground)));
        ?>
                    </div>
                    <div id="tabs-5">
                        <?php 
        $nums = ' .crayon-table .crayon-nums';
        $stripedNum = ' .crayon-striped-num';
        $markedNum = ' .crayon-marked-num';
        $stripedMarkedNum = ' .crayon-marked-num.crayon-striped-num';
        self::createAttributesForm(array(new CrayonHTMLTitle($tNumbers), array($tBorderRight, self::createAttribute($nums, 'border-right-width'), self::createAttribute($nums, 'border-right-color'), self::createAttribute($nums, 'border-right-style')), new CrayonHTMLSeparator($tNormal), self::createAttribute($nums, 'background', $tBackground), self::createAttribute($nums, 'color', $tText), new CrayonHTMLSeparator($tStriped), self::createAttribute($stripedNum, 'background', $tBackground), self::createAttribute($stripedNum, 'color', $tText), new CrayonHTMLSeparator($tMarked), self::createAttribute($markedNum, 'background', $tBackground), self::createAttribute($markedNum, 'color', $tText), array($tBorder, self::createAttribute($markedNum, 'border-width'), self::createAttribute($markedNum, 'border-color'), self::createAttribute($markedNum, 'border-style')), self::createAttribute($markedNum . $top, 'border-top-style', $tTopBorder), self::createAttribute($markedNum . $bottom, 'border-bottom-style', $tBottomBorder), new CrayonHTMLSeparator($tStripedMarked), self::createAttribute($stripedMarkedNum, 'background', $tBackground), self::createAttribute($stripedMarkedNum, 'color', $tText)));
        ?>
                    </div>
                    <div id="tabs-6">
                        <?php 
        $toolbar = ' .crayon-toolbar';
        $title = ' .crayon-title';
        $button = ' .crayon-button';
        $info = ' .crayon-info';
        $language = ' .crayon-language';
        self::createAttributesForm(array(new CrayonHTMLTitle($tToolbar), new CrayonHTMLSeparator($tFrame), self::createAttribute($toolbar, 'background', $tBackground), array($tBottomBorder, self::createAttribute($toolbar, 'border-bottom-width'), self::createAttribute($toolbar, 'border-bottom-color'), self::createAttribute($toolbar, 'border-bottom-style')), array($tTitle, self::createAttribute($title, 'color'), self::createAttribute($title, 'font-weight'), self::createAttribute($title, 'font-style'), self::createAttribute($title, 'text-decoration')), new CrayonHTMLSeparator($tButtons), self::createAttribute($button, 'background-color', $tBackground), self::createAttribute($button . $hover, 'background-color', $tHover), self::createAttribute($button . $active, 'background-color', $tActive), self::createAttribute($button . $pressed, 'background-color', $tPressed), self::createAttribute($button . $pressed . $hover, 'background-color', $tHoverPressed), self::createAttribute($button . $pressed . $active, 'background-color', $tActivePressed), new CrayonHTMLSeparator($tInformation . ' ' . crayon__("(Used for Copy/Paste)")), self::createAttribute($info, 'background', $tBackground), array($tText, self::createAttribute($info, 'color'), self::createAttribute($info, 'font-weight'), self::createAttribute($info, 'font-style'), self::createAttribute($info, 'text-decoration')), array($tBottomBorder, self::createAttribute($info, 'border-bottom-width'), self::createAttribute($info, 'border-bottom-color'), self::createAttribute($info, 'border-bottom-style')), new CrayonHTMLSeparator($tLanguage), array($tText, self::createAttribute($language, 'color'), self::createAttribute($language, 'font-weight'), self::createAttribute($language, 'font-style'), self::createAttribute($language, 'text-decoration')), self::createAttribute($language, 'background-color', $tBackground)));
        ?>
                    </div>
                </div>
            </td>
        </tr>

    </table>

    <?php 
        exit;
    }
 public static function capture_crayons($wp_id, $wp_content, $extra_settings = array())
 {
     // Will contain captured crayons and altered $wp_content
     $capture = array('capture' => array(), 'content' => $wp_content, 'has_captured' => FALSE);
     CrayonLog::debug('capture for id ' . $wp_id . ' len ' . strlen($wp_content));
     // Convert <pre> tags to crayon tags, if needed
     if (CrayonGlobalSettings::val(CrayonSettings::CAPTURE_PRE)) {
         // XXX This will fail if <pre></pre> is used inside another <pre></pre>
         $wp_content = preg_replace_callback('#(?<!\\$)<\\s*pre(?=(?:([^>]*)\\bclass\\s*=\\s*(["\'])(.*?)\\2([^>]*))?)([^>]*)>(.*?)<\\s*/\\s*pre\\s*>#msi', 'CrayonWP::pre_tag', $wp_content);
     }
     // Convert mini [php][/php] tags to crayon tags, if needed
     if (CrayonGlobalSettings::val(CrayonSettings::CAPTURE_MINI_TAG)) {
         $wp_content = preg_replace('#(?<!\\$)\\[\\s*(' . self::$alias_regex . ')\\b([^\\]]*)\\](.*?)\\[\\s*/\\s*(?:\\1)\\s*\\](?!\\$)#msi', '[crayon lang="\\1" \\2]\\3[/crayon]', $wp_content);
         $wp_content = preg_replace('#(?<!\\$)\\[\\s*(' . self::$alias_regex . ')\\b([^\\]]*)/\\s*\\](?!\\$)#msi', '[crayon lang="\\1" \\2 /]', $wp_content);
     }
     // Convert inline {php}{/php} tags to crayon tags, if needed
     if (CrayonGlobalSettings::val(CrayonSettings::INLINE_TAG)) {
         $wp_content = preg_replace('#(?<!\\$)\\{\\s*(' . self::$alias_regex . ')\\b([^\\}]*)\\}(.*?)\\{/(?:\\1)\\}(?!\\$)#msi', '[crayon lang="\\1" inline="true" \\2]\\3[/crayon]', $wp_content);
         // Convert <span class="crayon-inline"> tags to inline crayon tags
         $wp_content = preg_replace_callback('#(?<!\\$)<\\s*span([^>]*)\\bclass\\s*=\\s*(["\'])(.*?)\\2([^>]*)>(.*?)<\\s*/\\s*span\\s*>#msi', 'CrayonWP::span_tag', $wp_content);
     }
     // Convert [plain] tags into <pre><code></code></pre>, if needed
     if (CrayonGlobalSettings::val(CrayonSettings::PLAIN_TAG)) {
         $wp_content = preg_replace_callback('#(?<!\\$)\\[\\s*plain\\s*\\](.*?)\\[\\s*/\\s*plain\\s*\\]#msi', 'CrayonFormatter::plain_code', $wp_content);
     }
     // Add IDs to the Crayons
     CrayonLog::debug('capture adding id ' . $wp_id . ' , now has len ' . strlen($wp_content));
     $wp_content = preg_replace_callback(self::REGEX_ID, 'CrayonWP::add_crayon_id', $wp_content);
     CrayonLog::debug('capture added id ' . $wp_id . ' : ' . strlen($wp_content));
     // Only include if a post exists with Crayon tag
     preg_match_all(self::regex(), $wp_content, $matches);
     // We need to escape ignored Crayons, since they won't be captured
     $wp_content = self::crayon_remove_ignore($wp_content);
     CrayonLog::debug('capture ignore for id ' . $wp_id . ' : ' . strlen($capture['content']) . ' vs ' . strlen($wp_content));
     if (count($matches[0]) != 0) {
         // Crayons found! Load settings first to ensure global settings loaded
         CrayonSettingsWP::load_settings();
         $capture['has_captured'] = TRUE;
         CrayonLog::debug('CAPTURED FOR ID ' . $wp_id);
         $full_matches = $matches[0];
         $closed_ids = $matches[1];
         $closed_atts = $matches[2];
         $open_ids = $matches[3];
         $open_atts = $matches[4];
         $contents = $matches[5];
         // Make sure we enqueue the styles/scripts
         $enqueue = TRUE;
         for ($i = 0; $i < count($full_matches); $i++) {
             // Get attributes
             if (!empty($closed_atts[$i])) {
                 $atts = $closed_atts[$i];
             } else {
                 if (!empty($open_atts[$i])) {
                     $atts = $open_atts[$i];
                 } else {
                     $atts = '';
                 }
             }
             // Capture attributes
             preg_match_all('#([^="\'\\s]+)[\\t ]*=[\\t ]*("|\')(.*?)\\2#', $atts, $att_matches);
             // Add extra attributes
             $atts_array = $extra_settings;
             if (count($att_matches[0]) != 0) {
                 for ($j = 0; $j < count($att_matches[1]); $j++) {
                     $atts_array[trim(strtolower($att_matches[1][$j]))] = trim($att_matches[3][$j]);
                 }
             }
             // Capture theme
             $theme_id = array_key_exists(CrayonSettings::THEME, $atts_array) ? $atts_array[CrayonSettings::THEME] : '';
             $theme = CrayonResources::themes()->get($theme_id);
             // If theme not found, use fallbacks
             if (!$theme) {
                 // Given theme is invalid, try global setting
                 $theme_id = CrayonGlobalSettings::val(CrayonSettings::THEME);
                 $theme = CrayonResources::themes()->get($theme_id);
                 if (!$theme) {
                     // Global setting is invalid, fall back to default
                     $theme = CrayonResources::themes()->get_default();
                     $theme_id = CrayonThemes::DEFAULT_THEME;
                 }
             }
             // If theme is now valid, change the array
             if ($theme) {
                 $atts_array[CrayonSettings::THEME] = $theme_id;
                 $theme->used(TRUE);
             }
             // Capture font
             $font_id = array_key_exists(CrayonSettings::FONT, $atts_array) ? $atts_array[CrayonSettings::FONT] : '';
             $font = CrayonResources::fonts()->get($font_id);
             // If font not found, use fallbacks
             if (!$font) {
                 // Given font is invalid, try global setting
                 $font_id = CrayonGlobalSettings::val(CrayonSettings::FONT);
                 $font = CrayonResources::fonts()->get($font_id);
                 if (!$font) {
                     // Global setting is invalid, fall back to default
                     $font = CrayonResources::fonts()->get_default();
                     $font_id = CrayonFonts::DEFAULT_FONT;
                 }
             }
             // If font is now valid, change the array
             if ($font) {
                 $atts_array[CrayonSettings::FONT] = $font_id;
                 $font->used(TRUE);
             }
             // Add array of atts and content to post queue with key as post ID
             $id = !empty($open_ids[$i]) ? $open_ids[$i] : $closed_ids[$i];
             $code = self::crayon_remove_ignore($contents[$i]);
             $capture['capture'][$id] = array('post_id' => $wp_id, 'atts' => $atts_array, 'code' => $code);
             CrayonLog::debug('capture finished for post id ' . $wp_id . ' crayon-id ' . $id . ' atts: ' . count($atts_array) . ' code: ' . strlen($code));
             $is_inline = isset($atts_array['inline']) && CrayonUtil::str_to_bool($atts_array['inline'], FALSE) ? '-i' : '';
             $wp_content = str_replace($full_matches[$i], '[crayon-' . $id . $is_inline . '/]', $wp_content);
         }
     }
     // Convert `` backquote tags into <code></code>, if needed
     // XXX Some code may contain `` so must do it after all Crayons are captured
     if (CrayonGlobalSettings::val(CrayonSettings::BACKQUOTE)) {
         $wp_content = preg_replace('#(?<!\\\\)`([^`]*)`#msi', '<code>$1</code>', $wp_content);
     }
     $capture['content'] = $wp_content;
     return $capture;
 }