diff --git a/functions.php b/functions.php index fb6ec4d0..5bec0dbd 100644 --- a/functions.php +++ b/functions.php @@ -29,6 +29,7 @@ 'customizer', 'filters', 'helpers', + 'shortcodes', 'tags', ]; @@ -52,6 +53,7 @@ add_filter( 'excerpt_more', '\Aldine\Filters\excerpt_more' ); add_filter( 'query_vars', '\Aldine\Filters\register_query_vars' ); add_filter( 'wp_nav_menu_items', '\Aldine\Filters\adjust_menu', 10, 2 ); +add_filter( 'the_content', 'do_shortcode' ); add_action( 'widgets_init', '\Aldine\Actions\widgets_init' ); add_action( 'wp_enqueue_scripts', '\Aldine\Actions\enqueue_assets' ); add_action( 'updated_option', '\Aldine\Actions\add_color_variants', 10, 3 ); @@ -59,6 +61,10 @@ add_action( 'customize_preview_init', '\Aldine\Customizer\customize_preview_js' ); add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_color_contrast_validator' ); +// Shortcodes +add_shortcode( 'aldine_page_section', '\Aldine\Shortcodes\page_section' ); +add_shortcode( 'aldine_call_to_action', '\Aldine\Shortcodes\call_to_action' ); + // Catalog page: Network admin controls add_action( 'admin_enqueue_scripts', '\Aldine\Admin\admin_scripts' ); add_action( 'wp_ajax_pressbooks_aldine_update_catalog', '\Aldine\Admin\update_catalog' ); diff --git a/inc/helpers/namespace.php b/inc/helpers/namespace.php index 8764688a..d32eb7fd 100644 --- a/inc/helpers/namespace.php +++ b/inc/helpers/namespace.php @@ -308,7 +308,7 @@ function handle_contact_form_submission() { function has_sections( $post_id ) { $post_content = get_post_field( 'post_content', $post_id ); if ( ! empty( $post_content ) ) { - if ( strpos( $post_content, 'page-section' ) ) { + if ( strpos( $post_content, 'page-section' ) || strpos( $post_content, 'aldine_page_section' ) ) { return true; } else { return false; diff --git a/inc/shortcodes/namespace.php b/inc/shortcodes/namespace.php new file mode 100644 index 00000000..455513aa --- /dev/null +++ b/inc/shortcodes/namespace.php @@ -0,0 +1,58 @@ + 'Page Section', + 'variant' => '', + ], + $atts, + 'aldine_page_section' + ); + + return sprintf( + '