Filter
uncanny-automator
uap_option_all_pages
Filters the settings for all pages, allowing modification of page-specific options before they are saved or displayed.
add_filter( 'uap_option_all_pages', $callback, 10, 1 );
Description
Filters the array of available "Page" token options. Developers can add, remove, or modify these tokens to customize what page-related information can be used in Uncanny Automator workflows. This hook fires when tokens are being gathered for use with "Page" actions.
Usage
add_filter( 'uap_option_all_pages', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter is the current value of the `$option` being filtered, which represents the selected page option in the Uncanny Automator plugin.
Return Value
The filtered value.
Examples
/**
* Example: Add a new custom page option to the 'uap_option_all_pages' filter.
* This example demonstrates how to add a new option to the list of available
* page-related options that Uncanny Automator can use in automations.
*
* @param array $options The array of existing page options.
* @return array The modified array of page options, including the new one.
*/
add_filter( 'uap_option_all_pages', 'my_custom_automator_page_options', 10, 1 );
function my_custom_automator_page_options( $options ) {
// Add a new custom option for the page's featured image URL.
$options['PAGESLUG'] = esc_attr_x( 'Page Slug', 'WordPress', 'uncanny-automator' );
// You could also modify existing options or add more complex logic here.
// For example, to add the page's category:
// $options['POSTCATEGORY'] = esc_attr_x( 'Page Category', 'WordPress', 'uncanny-automator' );
return $options;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/wp/helpers/wp-helpers.php:252
public function all_pages( $label = null, $option_code = 'WPPAGE', $any_option = true ) {
if ( ! $label ) {
$label = esc_attr_x( 'Page', 'WordPress', 'uncanny-automator' );
}
$args = array(
// phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'posts_per_page' => apply_filters( 'automator_select_all_pages_limit', 999, 'page' ),
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'page',
'post_status' => 'publish',
);
$all_pages = Automator()->helpers->recipe->options->wp_query( $args, $any_option, esc_attr_x( 'Any page', 'WordPress', 'uncanny-automator' ) );
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $all_pages,
'relevant_tokens' => array(
$option_code => esc_attr_x( 'Page title', 'WordPress', 'uncanny-automator' ),
$option_code . '_ID' => esc_attr_x( 'Page ID', 'WordPress', 'uncanny-automator' ),
$option_code . '_URL' => esc_attr_x( 'Page URL', 'WordPress', 'uncanny-automator' ),
$option_code . '_POSTNAME' => esc_attr_x( 'Page slug', 'WordPress', 'uncanny-automator' ),
$option_code . '_EXCERPT' => esc_attr_x( 'Page excerpt', 'WordPress', 'uncanny-automator' ),
$option_code . '_CONTENT' => esc_attr_x( 'Page content (raw)', 'WordPress', 'uncanny-automator' ),
$option_code . '_CONTENT_BEAUTIFIED' => esc_attr_x( 'Page content (formatted)', 'WordPress', 'uncanny-automator' ),
$option_code . '_THUMB_ID' => esc_attr_x( 'Page featured image ID', 'WordPress', 'uncanny-automator' ),
$option_code . '_THUMB_URL' => esc_attr_x( 'Page featured image URL', 'WordPress', 'uncanny-automator' ),
'POSTAUTHORFN' => esc_attr_x( 'Page author first name', 'WordPress', 'uncanny-automator' ),
'POSTAUTHORLN' => esc_attr_x( 'Page author last name', 'WordPress', 'uncanny-automator' ),
'POSTAUTHORDN' => esc_attr_x( 'Page author display name', 'WordPress', 'uncanny-automator' ),
'POSTAUTHOREMAIL' => esc_attr_x( 'Page author email', 'WordPress', 'uncanny-automator' ),
'POSTAUTHORURL' => esc_attr_x( 'Page author URL', 'WordPress', 'uncanny-automator' ),
),
);
return apply_filters( 'uap_option_all_pages', $option );
}