Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Class: Example Module
- *
- * @package projectname
- * @subpackage modules
- */
- /**
- * Example Module
- */
- class Example_Module {
- /**
- * Construct
- *
- * @param bool|string $style_uri (Optional) Specify stylesheet URI.
- */
- public function __construct( $style_uri = false ) {
- $this->styles( $style_uri );
- }
- /**
- * Hero
- *
- * @param array $args Arguments.
- */
- public function hero( $args = array() ) {
- $defaults = array(
- 'heading' => 'Et eaque et suscipit et voluptate.',
- 'content' => 'Placeat sunt deleniti. Sed eum aut neque laboriosam repellendus quaerat.',
- );
- $args = wp_parse_args( $args, $defaults );
- ob_start();
- ?>
- <div class="hero">
- <h1 class="hero__heading"><?php echo esc_html( $args['heading'] ); ?></h1>
- <div class="hero__content">
- <?php echo wp_kses_post( $args['content'] ); ?>
- </div>
- </div>
- <?php
- echo wp_kses_post( ob_get_clean() );
- }
- /**
- * Styles
- *
- * @param bool|string $style_uri External stylesheet.
- */
- private function styles( $style_uri = false ) {
- ob_start();
- ?>
- <style>
- .hero {
- background: #ddd;
- padding: 2em 6em;
- }
- .hero__heading {
- font-size: 2em;
- }
- .hero__content {
- max-width: 600px;
- }
- </style>
- <?php
- wp_register_style( 'case-study', $style_uri, array(), '1.0.0' );
- wp_enqueue_style( 'case-study' );
- wp_add_inline_style( 'case-study', ob_get_clean() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement