What are the requirements of the plugin?
Since version 2.0 you need at least WordPress 4.9 running on your self-hosted WordPress installation AND PHP in a version greater than 7.0. If you don’t know how to update your PHP version, check this quick blog post for a start: How to update to the latest PHP version for WordPress.
How can I activate the plugin?
- Please upload the plugin files to your
/wp-content/plugins/
folder. - Then head to the “Plugins” section in your WordPress administration panel. Click “Activate”.
- After that you will be asked to enter your purchase code. Click here if you don’t know where you can find your Envato purchase code. Click the blue “Activate” button.
- That’s it! After that you should find a new menu item called “Content after Posts”.
What are the Actions and Filters I can use?
Filters
-
cap/blocks/allow
If you want to allow/disallow the CAP content block for Gutenberg post types. It’s activated for all posts and pages by default. Has one parameter:(bool) $allow
– default istrue
. -
cap/blocks/allow/{post_type}
Same as above but specific for a post type. -
cap/blocks/content
Hooks into the Gutenberg block content. Has one parameter:(string) $content
-
wpbcap_is_on_sql
Allows you to manipulate the SQL query. Has two parameters:(string) $sql
,(WP_Post) $post
-
wpbcap_custom_condition
Allows to add your own conditional checks for the visibility of a CAP. Must returnfalse
to skip including the CAP to the content. Has three parameters:(int) $cap_id
,(stdClass) $cap
,(WP_Post) $post
The $cap object has the following properties:(int) cap_id
,(array) post_types
,(string|array) include
,(string|array) exclude
,(int) priority
-
wpbcap_custom_condition_pre
Allows you to omit all conditions and include the CAP directly whentrue
is returned. Has three parameters:(int) $cap_id
,(stdClass) $cap
,(WP_Post) $post
-
wpbcap_content
Called whenever a “post after content” content gets printed. Has 4 parameters:(string) $content
,(int) $cap_id
,(string) $where
,(WP_Post) $post
-
wpbuddy/cap/rest-positions/permission
Permission check on REST API usage. Has two parameters:(bool) $current_user_can, (WP_REST_Request) $request
-
wpbuddy/cap/position/value_possibilities
Allows to hook into the possible position values. Has 4 parameters:(array) $values, (string) $q, (string) $page, (string) $param
-
cap/position/custom_params
Allows to add custom position parameters. Has one parameter:(array) $params
-
cap/position/params
Allows to manipulate the position parameters altogether. Has one parameter:(array) $params
-
cap/position/operators
Allows to change the operators. Has one parameter:(array) $operators
-
wpbcap_post_type_args
Gets called when the post typewpbcap
gets generated. Has one parameter:(array) $args
-
wpbuddy/cap/rule/match/bail_early
Allow to bail early on a single position rule. Has two parameters:(bool) $null, (Position_Rule) $rule
-
wpbuddy/cap/rule/{$method_name}
Allows to filter a return value from a specific rule method. Has two parameters:(mixed) $return_value, (Position_Rule) $rule
-
wpbuddy/cap/rule/match
Allows to filter the outcome of a rule match. Has two parameters:(mixed) $return_value, (Position_Rule) $rule
-
cap/position/values
Allows to change position values. Has to parameters:(array) $values, (Position_Rule) $rule
Deprecated filters < version 2.0.0:
-
wpbcap_config
Use this filter to change the config settings. Has one parameter:(array) $wpbcap_config
-
wpbcap_older_than
You can change the time for the “older than” parameter. Has one parameter:(int) $time_in_seconds
Actions
-
wpbcap/backend/init
Runs after backup init has run. -
wpbuddy/cap/metaboxes
Before metaboxes are added. -
wpbuddy/cap/metaboxes/no_block_editor
After non-block-editor metaboxes are added. -
wpbuddy/frontend/init
Runs after frontend init. -
wpbuddy/cap/upgrades
Runs when upgrades should be performed.
Deprecated action hooks < 2.0.0
-
wpbcap_before_{$type}_input
Use this to add HTML before a special setting on the settings page.$type
is the current settings type (ex. text, number, range, textarea, etc.). Can have two parameters (parsed by reference):(array) $args
,(mixed) $value
-
wpbcap_after_{$type}_input
Use this to add HTML after a special setting on the settings page.$type
is the current settings type (ex. text, number, range, textarea, etc.). Can have two parameters (parsed by reference):(array) $args
,(mixed) $value
How can I deactivate all CAPs (Content after Posts) on a single page or post?
That’s an easy one. ;-) Just edit the page and scroll down to the “Content After Posts” metabox. Then mark the checkbox “Don’t show CAPs”. That’s it ;)
Can I use it within a network installation (network enabled, using it on all sub-blogs)?
No. At the moment this is not possible. The plugin has to be activated on each plugin separately. But (as always) you can add a feature request.
Can i use it to put feature images for my old posts?
No. The reason for this is that WordPress’ content area does not allow dynamic content (like PHP). But maybe you can use this plugin: allow PHP in posts and pages.
Does this plugin load anything in the frontend, that will slow down the site?
The plugin has to check if there is a CAP (content after post) for the page that is currently called (otherwise it wouldn’t work). But it shouldn’t slow down your site. I always recommend the usage of a caching plugin anyway ;)
Is the priority setting also for the ordering of these items?
Yes. The priority allows to reorder the content (because other plugin can also add content to the top/end of a post/page/custom post type).
How can I remove the “About”, “Social Media” and “Help” section when editing a CAP?
Since Version 1.1.0. it’s possible to deactivate these sections through the language file. For example if you want to deactivate the “about” section open the language file /assets/langs/content-after-posts-en_US.po
with your favorite language editor (like PoEdit). Search for the Entry “on [Display “About” meta box (on|off)]” and translate it to “off”. Save your file. That’s it.
Notes:
- Don’t forget to do this with other language files, too.
- Don’t forget to upload the *.mo file via FTP to your webserver.
Does it work with Visual Composer?
Visual Composer is supported in versions lower 2.0. Since version 2.0 we only support the classic editor and the block editor (Gutenberg).
Please note that in some cases the “Backend Editor” button will not show up. In this case please do the following:
- Go to your WordPress dashboard.
- Go to “Settings” -> “Visual Composer”.
- Just hit the “Save Changes” button.
For those who are interested why this helps: my plugin hooks into the get_option
filter WordPress provides. If Visual Composer gets installed the first time, no settings/options are saved to the database (it just loads the default post types internally) and so the filter will be ignored. In fact: my plugin cannot hook into the filter to activate the CAP post type to show the “Backend Editor” button. Nerdy? Don’t worry… just hit he save button ;)
Does it work with the block editor (Gutenberg)?
Yes, since version 2.0.
Rule position help
Since version 2.0 it’s possible to generate your own ruleset that gives you full control where your text should show up. Here is some help what exactly the rules mean:
Content position
This is a required field. It defines where your new content should appear. After or before the main content of a page or if a text should be replaced.
Content priority
The plugin hooks into WordPress filters that allow to add a priority. For example, if you hook into the ‘the_content’ filter (see below) you may see that other plugins are using this filter as well. It could be that your CAP-text is not the last text on a post or a page. If this is the case, you can set a higher priority. A higher number means that the text is added later and therefore is below the text other plugins may add.
Content hook
This is a required field. As per default you should always hook into the ‘the_filter’ hook. This is the normal filter name for the content WordPress outputs on the frontend. Sometimes – and especially if you want to output text on special pages (like archives pages) – you need another filter because themes are sometimes using other filters instead of ‘the_content’.
Post type
This should be obvious. Select a post type.
Post
Select a single post, page or custom post type. Just enter some text and the plugin will search in the background.
Post Template
Some themes have custom post templates. You can select them here.
Post Status
If you want to target specific post status.
Post Format
In the old days you could choose between several post formats. You can select them here.
Post Category
This should be obvious.
Post Taxonomy
This should be obvious.
Page Template
Some themes have custom post templates. You can select them here.
Page Type
Select from a specific page type (like Frontpage, Blog page, etc.). Please note that some themes handle frontpages, blogpages differently. Just try to experiment with the settings to find what you need.
You can also set it to “all” do activate the CAP on every single page.
Page Parent
If you want to target subpages (choose a page parent here).
Post Published Date & Time
Enter a specific date and time (ie. 2018-11-24 16:00). The plugin will match against the posts published date.
Post Modified Date & Time
Enter a specific date and time (ie. 2018-11-24 16:00). The plugin will match against the posts last modified date.
Post Published Interval
Allows to enter a time interval. Please use the ISO 8601 duration specification for this field. It’s also possible to add time specific words in plain english like ‘8 days’ or ‘4 hours’.
The plugin will match against the posts published date.
Post Modified Interval
Allows to enter a time interval. Please use the ISO 8601 duration specification for this field. It’s also possible to add time specific words in plain english like ‘8 days’ or ‘4 hours’.
The plugin will match against the posts last modified date.
Current Date & Time
Allows to match against a current date and time. For example if a CAP should only be available from a specific date and time and/or between two dates. Use dates, like 2018-11-24 16:00 in this field.