The Code Editor is a DigiFlash Pro feature that allows you to add custom CSS, JavaScript, HTML, and PHP code to your WordPress site without editing theme files. This tool provides a centralized location for managing code snippets with syntax highlighting, organization, and automatic execution.
What the Code Editor Does
The Code Editor stores custom code snippets as individual items that execute automatically on your site. Each snippet can contain CSS styling, JavaScript functionality, HTML markup, or PHP functions that extend or modify your site’s behavior.
Unlike editing theme files directly, code snippets created in the Code Editor persist through theme updates and can be easily enabled, disabled, or deleted without affecting your theme’s core files. This approach keeps customizations separate from theme code and makes them easier to manage.
Accessing the Code Editor
After activating DigiFlash Pro, the Code Editor becomes available in your WordPress admin panel under Code Snippets in the main navigation menu. This dedicated section displays all your saved code snippets and provides options to create new ones.
The Code Editor interface shows a list of existing snippets with their titles, code types, and activation status. You can create unlimited snippets and organize them by purpose or functionality.
Supported Code Types
The Code Editor supports four types of code, each serving different purposes on your site.
CSS – Custom styles that modify the appearance of your site. CSS snippets load in the site header and apply to all pages where activated.
JavaScript – Scripts that add interactive functionality or modify page behavior. JavaScript snippets can load in the header or footer depending on your needs.
HTML – Custom markup inserted at specific locations on your site using WordPress hooks. HTML snippets work well for adding tracking codes, custom content sections, or third-party widgets.
PHP – Server-side code that extends WordPress functionality, creates custom functions, or modifies theme behavior. PHP snippets execute on WordPress hooks you specify.
Code Execution Methods
The Code Editor offers two execution modes for PHP code snippets to accommodate different coding styles and use cases.
Automatic Mode – Your PHP code is automatically wrapped in a function and executed on the WordPress hook you select. Write code without opening and closing PHP tags unless you need to switch between PHP and HTML within the snippet.
Manual Mode – You write complete, standalone PHP code including function definitions, hooks, and any necessary PHP tags. This mode gives you full control over code structure and execution, allowing complex implementations with multiple functions or conditional logic.
CSS and JavaScript snippets always execute automatically when active. HTML snippets insert at the hook location you specify without requiring additional wrapper code.
Hook Locations for PHP and HTML
PHP and HTML code snippets require you to specify where on your site they should execute. The Code Editor provides a dropdown of common WordPress hooks including wp_head, wp_footer, wp_body_open, and others.
These hooks determine when and where your code runs. For example, wp_head executes in the site header before the closing head tag, while wp_footer runs in the footer before the closing body tag. The wp_body_open hook places code immediately after the opening body tag.
You can also enter custom hook names if you need to execute code on specialized hooks provided by other plugins or specific theme locations. The priority setting controls the execution order when multiple functions hook into the same location.
Creating and Managing Snippets
To create a new code snippet, click Add New from the Code Snippets page. This opens the code editor interface where you enter your snippet title, select the code type, write your code, and configure execution settings.
Each snippet functions as a separate WordPress post type, allowing you to draft, publish, or trash snippets as needed. Only published snippets execute on your live site. Drafts remain saved but inactive until you publish them.
The snippet list shows all your code with options to edit, duplicate, or delete each one. You can quickly enable or disable snippets without deleting them, making it easy to test changes or temporarily remove code.
Code Editor Interface
The editor itself provides syntax highlighting based on your selected code type, making code easier to read and write. Line numbers appear on the left side for reference when debugging or discussing code.
The interface includes tabs or sections for entering your code, configuring settings like hook location and priority for PHP/HTML snippets, and viewing execution mode options for PHP code.
Help text and examples appear throughout the interface to guide you in writing correct code for each type. These examples demonstrate common use cases and proper syntax.
Considerations
PHP code errors can break your site if not written correctly. The Code Editor provides syntax highlighting but doesn’t validate code before execution. Ensure PHP snippets are error-free before publishing.
Custom code is your responsibility to maintain. DigiFlash Pro provides the tool to add code, but cannot provide support for debugging custom code snippets or ensuring they work correctly with your specific setup.