wp-plugin-boilerplate/includes/front/class-custompage.php

37 lines
1004 B
PHP

<?php
namespace PluginNamespace\Front;
class CustomPage {
public function __construct() {
add_shortcode( 'nmsp_plugin_shortcode', array( $this, 'display_custom_page' ) );
}
/**
* Display a page in place of a shortcode.
*
* @since 1.0.0
*
* @param array $attributes Array of attributes on the shortcode string in the post body.
* @param string $content (optional) Text content that is between opening and closing shortcodes.
*
* @return string
*/
public function display_custom_page( array $attributes = array(), $content = null ) {
$data = array(
'shortcode' => array(
'attributes' => $attributes,
'content' => $content,
),
);
// phpcs:disable WordPress.Security.EscapeOutput
return nmsp_plugin_app()->blade->run( 'front.custom-page', $data );
// phpcs:enable WordPress.Security.EscapeOutput
}
}
new CustomPage();