Salesforce Apex & VisualForce Syntax Highlighter for WordPress

  • submit to reddit

Salesforce Apex / Visualforce Syntax Highlighter

Salesforce Apex / Visualforce Syntax Highlighter

If you’ve ever used a search engine to find help on Salesforce development, then you’re probably familiar with Jeff Douglas. He is the inspiration behind this section of my blog. As a developer, I often find my self accumulating an ever growing array of help documents, useful functions, tips, shortcuts and commonly repeated code. Rather than hog them for my self, I decided to do what Jeff has been doing and share my knowledge with the online community.

Before I started to blog about Salesforce, I began looking for syntax highlighter wordpress plugins that might meet my needs. While the options were plentiful, none were specific to Salesforce and so I took it upon my self to develop my own. Now, to begin my first Salesforce post I share this plugin with you and a bit of information about how it came together.

Thanks to a post by Eric Santiago on his version of a Visualforce Syntax Highlighter for Typepad and a post by Alex on adding new brushes to Syntax Highlighter Evolved I was able to put together a WordPress plugin that works alongside the SyntaxHighlighter Evolved plugin in order to provide Apex & VisualForce sytanx highlighting.

You can download the plugin by clicking on this link: SyntaxHighlighter Evolved: Salesforce Apex & VisualForce Brush.

I’ve submitted the plugin to the depository so hopefully it will appear there soon.

Once you’ve installed both plugins, you can begin writing your code by using the following shortcodes:

[visualforce] [/visualforce]
[apex] [/apex]

Here’s an example of the Visualforce syntax:

<apex:page standardController="Opportunity" >
  <apex:sectionHeader title="Cancellation Approval"/>
  <apex:form >
      <apex:pageBlock title="Edit" mode="edit" id="thepageblock">
          <apex:pageblockButtons >
              <apex:commandButton value="Save" action="{!save}"/>
          <apex:pageBlockSection columns="1" title="Opportunity Details">
          <apex:outputField value="{!Opportunity.Name}"/>
          <apex:outputField value="{!Opportunity.Customer_Name__c}"/>
          <apex:outputField value="{!Opportunity.Hotel_Name__c}"/>
          <apex:outputField value="{!Opportunity.Booked_Room_Nights__c}"/>
          <apex:outputField value="{!Opportunity.Booked_Gross_Booking__c}"/>
          <apex:outputField value="{!Opportunity.Request_To_Cancel__c}"/>
          <apex:pageBlockSection columns="1" title="Approval Details">
          <apex:inputField value="{!Opportunity.Sales_Agent_Action__c}" required="true" />
          <apex:inputField value="{!Opportunity.Cancellation_Is__c}" required="true" >
              <apex:actionSupport event="onchange" rerender="thepageblock" status="status"/>
          <apex:inputField value="{!Opportunity.Sales_Agent_Outcome__c}" rendered="{!opportunity.Sales_Agent_Action__c == 'Called Customer' || opportunity.Sales_Agent_Action__c == 'Emailed Customer' || Opportunity.Cancellation_Is__c == 'Declined'}" required="true" style="width:500px;height:100px;"/>

Here’s an example for the Apex syntax:

trigger CreateActivityFromPublicTask on Public_Task__c (after insert) {
  List<Task> TasksToCreate = new List<Task>();
  for (Public_Task__c pt : {
    Task t = new Task();
    t.Priority = pt.Priority__c;
    t.ActivityDate = pt.Call_Back_Date__c;
    t.Call_Back_Time__c = pt.Call_Back_Time__c;
    t.Call_Back_Number__c = pt.Call_Back_Number__c;
    t.Description = pt.Comments__c;
    t.WhoId = pt.Lead__c;
    t.Status = pt.Status__c;
    t.Type = pt.Type__c;
    t.Subject = pt.Subject__c;
    t.IsReminderSet = pt.IsReminderSet__c;
    t.ReminderDateTime = pt.ReminderDateTime__c;
    t.OwnerId = pt.OwnerId;
  if(TasksToCreate.size() > 0) {
    insert TasksToCreate;

I have been working with the platform since 2003 in both administrative and development roles. I also have experience in web design working with HTML, CSS, Javascript, and PHP. I hold certification for the Developer program. I am also an employee of Model Metrics, a company.

  • Rob T


  • Bruce Yue


  • manoj

    I am new bee on wordpress. I have to implements sales force plugin for fetching records form sales force .I could not find any plugin please help me out .Thanks in advance

  • crop1645

    Anthony — Brilliant! Just set up my first SFDC blog with this plug-in today. Thanks so much.

  • ranu

    Hi Anthony,

    I downloaded plugin ‘SyntaxHighlighter Evolved: Salesforce Apex & VisualForce Brush.’ but please let me know where this plugin should be installed. And which one is hte second plugin you are talking about.

    Pleae let us know the steps to use this pluging.

Read previous post:
Who is Anthony Victorio?

Hello. I am Anthony Victorio. I would love to share all kinds of personal details about my self, however, identity...