public static function instance($extra_attr = array(), $id = NULL) { CrayonLog::debug('instance'); // Create Crayon $crayon = new CrayonHighlighter(); /* Load settings and merge shortcode attributes which will override any existing. * Stores the other shortcode attributes as settings in the crayon. */ if (!empty($extra_attr)) { $crayon->settings($extra_attr); } if (!empty($id)) { $crayon->id($id); } return $crayon; }
<?php require_once '../global.php'; require_once CRAYON_HIGHLIGHTER_PHP; // These will depend on your framework CrayonGlobalSettings::site_http('http://localhost/crayon/wp-content/plugins/crayon-syntax-highlighter/'); CrayonGlobalSettings::site_path(dirname(__FILE__)); CrayonGlobalSettings::plugin_path('http://localhost/crayon/wp-content/plugins/crayon-syntax-highlighter/'); // Should be in the header crayon_resources(); $crayon = new CrayonHighlighter(); $crayon->code('some code'); $crayon->language('php'); $crayon->title('the title'); $crayon->marked('1-2'); $crayon->is_inline(FALSE); // Settings $settings = array(CrayonSettings::NUMS => FALSE, CrayonSettings::TOOLBAR => TRUE, CrayonSettings::ENQUEUE_THEMES => FALSE, CrayonSettings::ENQUEUE_FONTS => FALSE); $settings = CrayonSettings::smart_settings($settings); $crayon->settings($settings); // Print the Crayon $crayon_formatted = $crayon->output(TRUE, FALSE); echo $crayon_formatted; // Utility Functions function crayon_print_style($id, $url, $version) { echo '<link id="', $id, '" href="', $url, '?v=', $version, '" type="text/css" rel="stylesheet" />', "\n"; } function crayon_print_script($id, $url, $version) { echo '<script id="', $id, '" src="', $url, '?v=', $version, '" type="text/javascript"></script>', "\n";