*/ protected function input_properties(): array { return array( 'header' => array( 'type' => 'string', 'description' => __( 'Markup for the site head. Replaces the current value entirely.', 'acrossai-abilities-manager' ), ), 'body' => array( 'type' => 'string', 'description' => __( 'Markup for just after the opening body tag. Only rendered by themes that call wp_body_open.', 'acrossai-abilities-manager' ), ), 'footer' => array( 'type' => 'string', 'description' => __( 'Markup for the site footer. Replaces the current value entirely.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'header' => array( 'type' => 'string' ), 'body' => array( 'type' => 'string' ), 'footer' => array( 'type' => 'string' ), 'updated' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ), 'description' => __( 'Which slots were changed.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true ); } /** * @since 0.0.34 * @return bool */ protected function requires_confirmation(): bool { return true; } /** * @since 0.0.34 * @return string */ protected function confirmation_message(): string { return __( 'This markup is output on every page of the site. Pass confirm: true to proceed.', 'acrossai-abilities-manager' ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $slots = array_intersect_key( $input, Snippet_Repository::GLOBAL_KEYS ); if ( empty( $slots ) ) { return new WP_Error( 'invalid_input', __( 'Supply at least one of header, body or footer.', 'acrossai-abilities-manager' ) ); } $result = Snippet_Repository::update_global_scripts( $slots ); if ( is_wp_error( $result ) ) { return $result; } return array_merge( $result, array( 'updated' => array_keys( $slots ) ) ); } }