About Codex V2

What is a Codex?

A codex is an ancient book made of stacked, hand-written pages. A historian might study a medieval codex full of beautiful calligraphy and illustrations decorated with gold leaf.
The ancient Romans invented the codex. When the codex first appeared as a way to bind a manuscript, it was a great improvement over previous methods. One of these was the scroll, a long roll of paper, and another was a wax tablet. Codex is a Latin word used to mean "book of laws," although it's literally "tree trunk." The plural of codex is codices.

https://www.vocabulary.com/dictionary/codex

That's one official definition, anyway. In today's parlance, Codex means "an official list of chemicals or medicines, etc." In this case, "etc." means an "unofficial" list of Formidable Forms developer assets. We say "unofficial" because the data has neither been confirmed nor denied by anyone on the Strategy 11 Mothership.

What we can promise, is that our Codex V2 is the most complete and accurate index of Formidable's anatomy that you can find anywhere, except perhaps for Strategy 11's private vault.

If you're a serious developer who plans on making a living, or at least a portion of it, writing Formidable applications and add-ons, then you'll enjoy how Codex V2 documents and cross-references classes, the building blocks for all things Object-Oriented Programming related.

Codex V2

The Formidable Forms Codex V2 is a labor of love contributed to and used by Formidable Masterminds Developers the world over. It is a living database of Object Oriented Classes, Methods, and WordPress Hooks built into Formidable Forms. Ergo, available for the savvy developer to use in your own customizations, applications, and add-ons.

Codex V2 is the most complete Formidable Forms developer documentation available anywhere, addressing the shortcomings of the V1 release, curated when Views were still a part of Formidable Pro. Built from the ground up, Codex V2 hook entries include the link to each entry's respective Formidable KnowledgeBase page, if there is one, as well as real-life examples and comments contributed by Mastermind Developers.

Beyond what could be linked to the KnowledgeBase, Codex V2 has an entry for every hook found in all Formidable Add-on source codes. Maybe it surprises you to learn that some add-ons don't have any WordPress Hooks at all. "Not having any hooks" means the code is locked to outside developers unless it's possible for you to create a child class by extending a parent to meet your customization goals through inheritance.

Here are the add-ons that have no WordPress Hooks:

Even though these add-ons have no WordPress hooks, it doesn't mean you can't extend them to add your own actions and filters through object-oriented inheritance. Unless, that is, the class you need to extend has been declared as a final class. Final classes cannot be extended in object-oriented programming.

Because final classes cannot be extended, protected and protected static methods are not available to the developer. Examples of final classes are found in Formidable's HubSpot and GoogleSheets add-ons.

When you view the content for the add-on you're seeking, hook entries with links to the KnowledgeBase are shown with a super-scripted mini-Formidable logo, as shown in the add-on list above. When clicked, it will open the linked KnowledgeBase page in a new browser tab.

Codex V2 is just one example, and a rather simple one at that, of an application that can be built using Formidable Forms. Well, maybe not so simple after all, but it is a great example!

Codex V2 consists of the following records:

  • Codex V2 Entries: 10,798
  • Classes: 997
  • Methods: 8,746
  • Actions: 311
  • Filters: 790
  • Dynamic Actions: 37
  • Dynamic Filters: 38
  • Hooks with KB Links: 428
    Formidable Forms logo
  • Hooks without KB References: 673
    Undocumented hooks are a treasure trove of opportunities waiting to be explored by innovative developers!
  • Actions with KB Links: 89
    Formidable Forms logo
  • Filters with KB Links: 339
    Formidable Forms logo
  • Hooks in the "Creating add-ons" topic: 43

The record counts shown above are extracted in real-time from the Formidable frm_item_metas table via a custom shortcode.

About Formidable's Code

Above all else, Formidable is an exemplar of Object-oriented programming that provides a capable development environment for capturing and reporting data.

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or properties), and the code is in the form of procedures (often known as methods).

https://en.wikipedia.org/wiki/Object-oriented_programming

While Codex V2 entries can't teach you OOP's nuances when developing with Formidable Forms, it can help you locate code that you might find useful while testing undocumented hooks. "Undocumented hooks" means actions and filters that can be found in Formidable's source code, but for which no reference can be found in the Formidable KnowledgeBase.

Undocumented hooks are a treasure trove of opportunities waiting to be explored by innovative developers. In these cases, if you think an undocumented hook may be useful to your project and want to find out how to use it properly, you have to test it to examine its parameters. This is what makes software development fun: proving concepts and testing new code.

If you are registered in the Formidable Masterminds Developers Directory, there's a Developers Corner tutorial that will be a "How to Use This Resource" video available to you shortly that explains how to test undocumented hooks. Thank you Nick Amis of Entapris Ltd for the suggestion!

Developers Corner content is free for registered developers.

Classes

A PHP class, and more generally, object-oriented programming, provides additional approaches to reusability, and can be used for a variety of purposes: They can describe entities that have known properties and behaviors. They can be used as messages to functions and other objects.

Zend Technology

Classes are the foundation of object-oriented programming. Researching class structures when working on an enterprise project is a required skill. No developer knows it all. The best developers know how to find the answers quickly and easily. And when it comes to Formidable Forms, Codex V2 has done the research for you.

The file locations for all classes are listed so you can review the source code for methods and hooks should you have a need to see how the Formidable developers intended them to be used.

OOP Classes are programmer-defined data types, which include local functions as well as local data. You can think of a class as a template for making many instances of the same kind (or class) of object.

Formidable's OOP Classes are Simple, Parent, Extends, Abstract, Implements, Final, or Interface. Many classes implement or extend WordPress and PHP classes, as well. These classes are also documented with links to their respective language/developer references. Classes are easily identified in Codex V2 by their icon or combination of icons:

  • Parent Class
  • Extended or Child Class
  • Abstract Class
  • Implements Class
  • WordPress Class
  • Final Class
  • OOP Interface
  • PHP Class

Simple classes do not have icons.

Classes can be multi-type. For example, classes can be a combination of a Parent, Extends, Abstract, and Implements. It's not unusual to find an Extends class that's a Parent of another Extends class.

In PHP, Extends and Implements are cousins. They both extend classes. The difference is that extends is used to get attributes of a parent class and its already defined methods and properties that can be overridden in the child class.

Whereas, implements is used to implement an interface by defining its methods in the child class. Interfaces allow you to specify what method names a class should implement without defining the method body. Interfaces make it easy to use a variety of different classes in the same way. When one or more classes use the same interface, it is referred to as "polymorphism".

Interfaces are similar to abstract classes. The difference between interfaces and abstract classes are:

  • Interfaces cannot have properties, while abstract classes can.
  • All interface methods must be public, while abstract class methods are public or protected.
  • All methods in an interface are abstract, so they cannot be implemented in code and the abstract keyword is not necessary.
  • Classes can implement an interface while inheriting from another class at the same time.

An example of an abstract class that is a child class of a PHP class that implements an interface can be found in this Stripe add-on declaration:

abstract ApiErrorException extends \Exception implements ExceptionInterface

When displayed in the Codex Class listings for the Stripe add-on, this is what you'll see:

\Stripe\Exception\ApiErrorException

Wherever possible, class entries are cross-referenced to make it easier to follow the execution path when debugging or reverse engineering code to learn how to "DIY".

Methods, Actions, and Filters are cross referenced to the classes to which they belong. These class references are linked to the Class entry. Hyperlinks in any entries are generated on-the-fly through custom code executed in the frm_display_entry_content filter.

Methods

In object-oriented programming (OOP), a method is a programmed procedure that is defined as part of a class and is available to any object instantiated from that class. Each object can call the method, which runs within the context of the object that calls it. This makes it possible to reuse the method in multiple objects that have been instantiated from the same class.

https://www.techtarget.com/whatis/definition/method

Codex V2 includes abstract, public, public static, protected, and protected static methods:

  • Abstract methods are created when the developer (either oneself or someone else) commits to write a certain class method, but is only sure about the name of the method and not the details of how it should be written.
  • Methods declared public can be accessed everywhere.
  • Methods declared protected can be accessed only within the class itself and by inheritance.
  • Methods declared as private are not included in Codex V2 and may only be accessed by the class that defines the methods.
  • Declaring methods as static makes them accessible without needing an instantiation of the class. These can also be accessed statically within an instantiated class object.

As with classes, methods have their own set of identification icons:

  • Abstract Method
  • Public Method
  • Protected Method
  • Static Method

Public and public static methods are executed differently:

  • The syntax for public static methods is Class::method_name()
  • Public methods without the static keyword require you to instantiate a new instance of its parent class object.
    • Instantiation Example: $myclass = new class();
    • Method Call: $myclass->method();

WordPress Hooks

Actions and filters are types of WordPress hooks. They are WordPress hooks because Formidable uses the WordPress Plugin API to create its custom hooks. Formidable has both dynamic and static hooks.

Dynamic hooks can be used in many ways. The dynamic portion of the hook name is built using variables. Formidable has many dynamic hooks. Example of these include 'frm_after_update_entry_' . $new_values['form_id'] (Action) and 'frm_entries_' . $col_name . '_column' (Filter).

In most cases, it's nearly impossible to know the name of a static hook that correlates to its dynamic hook counterpart just by reading the source code. It takes some advanced debugging skills or a deep knowledge of Formidable to determine the actual hook name.

Static hooks are the ones with which you may be most familiar. Their names are spelled out in readable text. Examples of static hooks include frm_after_field_created (Action) and frm_field_html_id (Filter).

Wherever possible, Codex V2 entries cross reference static link realizations with their correlated dynamic link counterpart.

How You Can Help

It's our hope that Formidable Masterminds everywhere will help contribute to Codex V2. Every detail page has a Mastermind Contribution form on it, as well as a Formidable view to display approved contributions. Think of it like a Stackoverflow, but strictly for Formidable/WordPress developers that offer to share their knowledge as one of the best in the top Formidable Developer Directory in the world. There's nothing more profitable than building a great reputation in the Formidable Community.

If you're a coder and found novel ways to use Formidable's object-oriented classes, methods, actions, or filters, especially the undocumented hooks, would you kindly consider posting your contribution?

Chances are high that if you have had a requirement that you fulfilled using Formidable's many developer hooks that has not been documented, you can rest assured that somebody else may also be looking for a solution to the same problem. Please strongly consider letting your voice be heard?

We also welcome guest tutorials, tips & tricks, and code snippets. If you write posts like this for your own site and want to share your content here, we'll be sure to set the canonical URL to reference the content on your site. Please contact us at [email protected] to share your interests.

Thank you!