Advanced Customizing Styling - TenthPres/TouchPoint-WP GitHub Wiki

There are a bunch of ways to change the look and feel of how this plugin generates content on your site.

Filters

tp_include_actions_style

Use this filter to prevent the default Actions CSS from being imported. These CSS rules mostly clean up the formatting of form fields within SweetAlert dialogs. The filter will provide a string for each potential action.

If you're customizing CSS, consider importing the styles from touchpoint-wp/assets/template/actions-style.css and adding something like Example 1 to your functions.php file.

Example 1: Prevents the Actions CSS from being imported in all cases.

add_filter('tp_include_actions_style', '__return_false');

Example 2: Prevents the Actions CSS from being imported, if RSVP is the only action on the page.

function my_exclusion_of_rsvp_action_style($value, $action) {
    if ($action === "rsvp") {
        return false;
    }
    return $value;
}
add_filter('tp_include_actions_style', 'my_exclusion_of_rsvp_action_style');

tp_use_default_templates

By default, TouchPoint-WP provides templates for its post types that will typically work better than generic archive and single templates. However, if you use a specialized templating engine, you may not want this. This filter allows you to disable this functionality. The class name of the post is provided as an argument.

Example: Prevents the default templates from being used in all cases. (We use Timber for our site, and use this.)

add_filter('tp_use_default_templates', '__return_false');

tp_use_css

By default, TouchPoint-WP will require CSS file(s) when needed. If you specifically want to prevent these from being included, set this to false.

Example: Prevents the default css from being used in all cases. (We use this.)

add_filter('tp_use_css', '__return_false');

Imported HTML

Descriptions of Involvements, Meetings, and Partners are written in TouchPoint, and can include HTML. When that HTML is imported, it's standardized so that it's safe to publish and looks consistent in your theme. In order:

  1. Elements that shouldn't be shown or run, such as script and style, are removed along with their content.
  2. Attributes that could run code, such as onclick, are removed. So are links and image addresses that have a protocol that isn't allowed, such as javascript:.
  3. Tags that aren't allowed are removed, but their content is kept. By default, the allowed tags are paragraphs, line breaks, links, emphasis (em, strong, b, i, u), lists, headings, tables, images (img, figure, figcaption), blockquote, code, pre, div, and span.
  4. Headings are shifted so that the highest heading is an h2, and the headings below it keep their relationships.
  5. Whitespace at the start and end is removed.

Steps 1 and 2 read the HTML and write it out again, so the formatting of what's left can change a little. For example, tag names become lower case, and addresses in links are percent-encoded.

All of the filters below are given an extra argument that indicates the context of the standardization: involvement-import, meeting-import, or partner-import.

tp_standardize_html

To bypass this standardization and implement your own, use this filter. If the filter changes the HTML, none of the steps above are run.

tp_standardize_strip_content_tags

This filter returns an array of strings representing tags that are removed along with their content. The default is script, style, iframe, object, embed, and head. These tags are removed even if they are also allowed by tp_standardize_allowed_tags.

Example: Also removes figure elements, including their captions.

add_filter('tp_standardize_strip_content_tags', fn($tags) => [...$tags, 'figure']);

tp_standardize_allowed_tags

This filter returns an array of strings representing tags that are allowed to be imported from TouchPoint. Tags that aren't allowed are removed, but their content is kept. Tags are listed by name, without angle brackets.

Example: Allows section and small.

add_filter('tp_standardize_allowed_tags', fn($tags) => [...$tags, 'section', 'small']);

tp_standardize_allowed_protocols

This filter returns an array of strings representing the protocols that are allowed in addresses, such as the href of a link or the src of an image. The default is http, https, mailto, and tel. Addresses without a protocol, such as /about or #top, are always allowed. Attributes that have an address with any other protocol are removed.

Example: Allows links to FTP sites.

add_filter('tp_standardize_allowed_protocols', fn($protocols) => [...$protocols, 'ftp']);

tp_standardize_h_tags_max_h

This filter sets the highest heading level that's allowed. The default is 2, meaning h2.

tp_pre_standardize_html

This filter is run before the other HTML standardization processes as part of the HTML import process.

tp_post_standardize_html

This filter is run after the other HTML standardization processes as part of the HTML import process.

⚠️ **GitHub.com Fallback** ⚠️