Initially all closed Global Blocks are in the unloaded state until they are opened. When it changes into the open state, it will then be loaded from the server. This means when you go into the main CJT block management page, all closed blocks are still not loaded from the server. Only basic details that identify the blocks are loaded, so users can take any primary actions that does not require the block to be loaded such as clicking the Activate/Deactivate or Header/Footer toggle switches. If more actions need to be taken (such as code editing), then the block needs to be loaded by clicking on the block toolbar.

Loading the block would fetch block code, initialise the code editor, and other resources such as the Assignment Panel window and so on. When this happens, the block is in the loaded state and ready for editing.

Block state is saved in your user profile so it would always be in the same state next time you access/refresh the CJT block management page.

It’s highly recommended to close all your code blocks before leaving CJT blocks manager page. This is very important because loading many blocks when the page is loading might cause the browser to crash or cause a server time out error. CJT blocks have no pagination. It has been tested with more than 600 closed blocks and works perfectly fine, however opening say all of them at once would most-certainly prevent them from opening due to the server error.

When to use?

In some cases, users might need to cover more areas/requests where the assignment items fall short. This is when Expressions can be used and passed to the CJT Assignment Panel.

What kind of Expression is it?

CJT currently supports only Regular Expression as PHP, except that you don’t need to write the Expression delimiters. The expression will be automatically wrapped by the forward-slashes /EXPRESSION/ delimiters.

Difference Between Expressions and URLs

Although URLs are a custom assignment, each URL can only cover a single WordPress request. Since each URL is internal and can only point to a single request, Expressions on the other hand can evaluate what URLs it has to apply the block with.

How it’s being evaluated

The CJT expressions parser accepts a list of expressions separated by a new line. In other words, each line would contain a full single expression.

Each expression (line) would be automatically wrapped by double forward slashes (as specified by PHP) and then evaluated to the current request URL. Once a single expression is valid and matching, the block is then added to the In-Load Blocks Queue (IBsQ). The blocks queue will process and then go onto the next block that has expressions and repeat.

Regular Expression References

PHP Offical Regular Expression

Examples using Expressions

Matching all the site pages including frontend and backend:

.+

Matching all Pages that start with ‘mypage’ including the ‘mypage’ page:

\/mypage.*

Matching any page that contains the word ‘test’:

test.*

Matching any page that ends up with the word ‘test’:

test\/$

When to use?

As in some cases, users might need to cover more areas/requests where the assignment items are just not enough. URLs can be passed through the CJT Assignment Panel.

CJT URL parser accepts a list of URLs separated by a newline. so each line would have the full URL you wish to use. You must write the full URL including the WordPress home page/domain. CJT is not adding any trailer or prefixes to the URL you write.

CJT URL checker is splitting all URLs that are being passed, checking if it’s exactly equal the current request URI based on the PHP $_SERVER[‘REQUEST_URI’) and $_SERVER[‘HTTP_HOST’]. The URL can contain a custom Port number, with either HTTP or HTTPS is being supported.

Example of using URLs include:

Home Page: http://mywordpresssite.com/

WordPress Page: http://mywordpresssite.com/mypage/

Secure HTTP: https://mysecurewordpressite

Custom Port Number: http://mysecurewordpressite:PORT-NUMBER

As most WordPress sites almost always have some form of custom posts (Products, Downloads, etc) created by using other plugins and themes, CJT supports assigning Global Blocks to custom posts.

Custom posts might be hierarchical like WordPress Pages or flat like WordPress Posts. CJT is able to detect the custom post type and list it hierarchically or flat as defined.

Based on the custom post layout, CJT will display it hierarchically like pages with secondary shaded checkboxes, or flat like posts. However all custom posts are listed under a single Assignment Panel tab with a toggle-able list inside. If there are no custom posts defined, then a notice message will show in place of the list.

Note: Only custom posts that have dashboard admin page and front-end access would be listed under the Custom Posts tab. Other custom post types such as Logs, History, etc, which is only intended to be used internally by the plugin or theme should not be listed.

Auxiliary assignments are predefined assignments that group some common WordPress request types.

When assignments are required for cases where: the request currently exists AND the request does not yet exist, then it would be a good idea to use Auxiliary assignments. Auxiliary assignments give you the option of assigning a block to WordPress request items (e.g. posts, pages, categories, etc) whereby the item does not yet exist, so that whenever a new item gets added, it’s automatically added to the list.

It can also simplify assigning a block to a large group of WordPress items that cannot be assigned directly, as it would take sometime, or as it has not even been presented as WordPress items. Most of the Auxiliary assignments do logically exist but not physically on the database or disk.

Auxiliary assignment types

  • Entire Website: Apply to WordPress entire frontend website
  • Website Backend: Apply to WordPress dashboard/backend
  • All Pages: Apply to all WordPress pages that do not yet exist
  • All Posts: Apply to all WordPress posts that do not yet exist
  • Blog index: When Settings->Reading->’Front page displays’ with the option being set to show ‘Your latest posts’ for the homepage, then this Auxiliary assignment will apply to the blog index page
  • All Categories: Apply to all WordPress categories and all posts laying under those categories even though they do not yet exist
  • Search Pages
  • 404 Error: Apply to error page when WordPress cannot reach the requested item
  • Tag Archive
  • Author Archive
  • Attachments Archive
  • All Archive: Includes all of the above archives (including categories). However, it has the lowest priority, so if any archive assignment from the above items are being assigned, then that would take a priority over the All Archive assignment

Why Assign to a Category?

By assigning a Global Block to a category, you are applying the block to the category Archive (index) page and all the posts laying under that category! Yes, this is it. The idea behind applying blocks is to include all the child posts.

When assigning a block to a category, only that category and child posts would get the block applied. It doesn’t include the child categories automatically by default. This is intended so users can get more control by selecting the child categories (sub-categories) manually. Applying a block to all the child categories can be a problem if a few categories in the tree should not be included.

Assigning to single/multiple Categories

As the nature of WordPress Categories are hierarchical, the CJT Assignment Panel also reflects that in the Categories tab. It list all WordPress Categories in a hierarchical form so that a user can find the relation between categories while assigning a block.

Include many or all child Categories

CJT provides a shaded secondary checkbox for every parent category that help users to check/uncheck all the child categories with a single click. It is still possible to uncheck some child categories after selecting all with the secondary checkbox. This is part of the helper tools that is intended to give you the maximum combination – that often fits most cases, and all for minimal work.

Assigning to All Categories

In order to assign a block to all categories, you should use the Auxiliary tab in the Assignment panel, and then check the ‘All Categories’ option. Checking this would apply the block to all categories – even those that would be added in the future. It’s like a live event that will always automatically assign new categories to the existing category set.

Assigning single/multiple Posts

As the nature of WordPress Posts are flat (non-hierarchical), the assignment is straight-forward to the post itself and doesn’t include any other posts or categories that the post is related to.

The Post tab in the Assignment Panel provides you with the entire list of all existing posts in a flat, non-hierarchical form.

Assigning to All Posts

In order to assign a block to all posts, you should use the Auxiliary tab in the Assignment panel, and then check the ‘All Posts’ option. Checking this would apply the block to all posts – even those that would be added in the future. It’s like a live event that will always automatically assign new posts to the existing post set.

When assigning a block to a page, only that page would get the block applied. It doesn’t include the child pages automatically by default. This is intended so users can get more control by selecting the child pages (sub-pages) manually. Applying a block to all the child pages can be a problem if a few pages in the tree should not be included.

Assigning to single/multiple Pages

As the nature of WordPress pages are hierarchical, the CJT Assignment Panel also reflects that in the Pages tab. It list all WordPress Pages in a hierarchical form so that a user can find the relation between pages while assigning a block.

Include many or all child Pages

CJT provides a shaded secondary checkbox for every parent page that help users to check/uncheck all the child pages with a single click. It is still possible to uncheck some child pages after selecting all with the secondary checkbox. This is part of the helper tools that is intended to give you the maximum combination – that often fits most cases, and all for minimal work.

Assigning to All Pages

In order to assign a block to all pages, you should use the Auxiliary tab in the Assignment panel, and then check the ‘All Pages’ option. Checking this would apply the block to all pages – even those that would be added in the future. It’s like a live event that will always automatically assign new pages to the existing page set.

CJT is basically built over the assignment/association feature that allow users to run their codes in parallel with WordPress requests. A single Global Block might be assigned to multiple requests at the same time. This feature can be done through the Assignment Panel window.

The Assignment Panel can be classified into three parts:

  • WordPress (Posts, Pages, Custom Posts and Categories)
  • Auxiliary  (All Pages, All Posts, Blog index, etc)
  • Advanced (URL’s and Expressions)

By assigning Global Blocks to a WordPress request, you’re simply telling CJT to load these blocks when that specific request is submitted to the server. CJT would then prepare the blocks, run them, and provide the output.

Global Blocks can be reordered so that the top (higher up) blocks would be executed first before the bottom (lower down) blocks. Ordering Global Blocks can be very useful especially when functionality or output is dependant on the execution order. If for example you need to move a number of bottom (lower down) blocks higher up to override blocks above, you need to do the following:

  1. Drag the block you want to move by clicking the block toolbar
  2. Drop it in the new position
  3. After re-ordering all target blocks, click ‘Save All’ Changes’ button

 
Note: Nothing will be saved until the ‘Save All Changes’ button is clicked. As long as you have not clicked the ‘Save All Changes’ button, you can revert the block orders back by simply refreshing the page.

Deleting CJT Global Blocks can be done by clicking on the Delete (cross icon) from the block main toolbar. You’ll then need to confirm the delete message.

After confirming the deletion, nothing actually deletes just yet as the block is only removed from the UI list. You have to click the ‘Save All Changes’ button from the CJT main toolbar to save the deleted blocks.

Currently CJT is not supporting a way so the deleted blocks can be reverted back when the ‘Save All Changes’ button has not been clicked, however we plan to do that soon. So if you need to undo deleting your blocks, as long as did not click the ‘Save All Changes’ button, you can simply refresh the page to get them back.

Warning: After clicking the ‘Save All Changes’ button, blocks cannot be reverted back as they are permanently deleted from the database. Therefore, all the deleted blocks data will be lost.

Creating a Global Block is a very simple process that can be done by clicking the ‘Create New Block’ button from the CSS & Javascript Toolbox dashboard page. You will have to fill out the Create New Code Block form and click OK.

New Block Fields:

  • Name: Block name that will be used for giving a hint about the block function and to be used as the shortcode name/parameters
  • Activate: Check it to initially Activate the newly created block, or leave it unchecked to initially make it disabled. Value can be changed later
  • Location Hook: Header/Footer is the initial location hook for the block, where the block would be executed and outputted
  • Position: The block order position for the Global Blocks list allows block creation in either the first block position (default position) or the last block position. The top (higher up) blocks would be executed first before the bottom (lower down) blocks

After the block has been created the popup form will close and the new block is added on the main Global Blocks manager page. It will be initially loaded/opened and the keyboard cursor will be activated for the code editor, allowing you to write code directly on there.

Global Blocks is the Block type that works globally and can be assigned to multiple WordPress requests. CJT Global Blocks can be created through the CSS & JavaScript Toolbox main dashboard.

A Global Block has two components that build up the Global Block unit. The Code Editor and the Assignment Panel. The Assignment Panel allows you to assign the code block to multiple WordPress requests via both predefined and custom requests. Please visit the @Assignment Panel documents for more information.

Global Blocks share a few attributes and one of them is the order. Global Blocks can be reordered so that the top (higher up) blocks would be executed first before the bottom (lower down) blocks. This can be useful when you require a higher block to override a lower block.

You will notice that all Global Blocks are created in one single page and they are not categorised. With many blocks in play, this may get confusing to know the order of block execution, and whether some will not get involved on the same request. In the near future, CJT will be organised as separate individual Projects where each Project may contain multiple Global Blocks inside.

All Global Blocks are automatically assigned a shortcode with its name and can be used directly by typing the shortcode into the page or post content. Please visit @Shortcode section for more information about Global Block shortcodes.