Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request 10up#129 from alleyinteractive/iframe-fix
Browse files Browse the repository at this point in the history
iframe fix
  • Loading branch information
jameswburke authored Jun 11, 2019
2 parents 0f25c77 + 037a9eb commit 5494edb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions themes/cpr/components/content/class-newsletter-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function post_has_set() : self {
'url',
esc_url(
str_replace(
home_url(),
site_url(),
home_url() . '/newsletter-single/',
'/iframe/newsletter/',
$this->wp_post_get_permalink()
)
)
Expand Down
16 changes: 16 additions & 0 deletions themes/cpr/components/templates/class-newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function get_components() : array {
*/
( new \CPR\Components\Column_Area() )
->set_theme( 'oneColumn' )
->set_config( 'heading', $this->wp_post_get_title() )
->append_children(
[
( new \CPR\Components\Content\Newsletter_Content() )
Expand All @@ -53,4 +54,19 @@ public function get_components() : array {
),
];
}

/**
* Modify rewrite rules.
*/
public static function dispatch_rewrites() {
\Alleypack\Path_Dispatch()->add_path(
[
'path' => 'iframe-newsletter',
'rewrite' => [
'rule' => 'iframe/newsletter/(.*)/?',
'redirect' => 'index.php?post_type=newsletter-single&name=$matches[1]',
],
]
);
}
}
6 changes: 6 additions & 0 deletions themes/cpr/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
define( 'CPR_PATH', dirname( __FILE__ ) );
define( 'CPR_URL', get_template_directory_uri() );

// Handle local dev port issues.
if ( false !== strpos( site_url(), 'alley' ) ) {
remove_filter( 'template_redirect', 'redirect_canonical' );
}

/**
* Alleypack modules.
*/
\Alleypack\load_module( 'block-converter', '1.0' );
\Alleypack\load_module( 'cli-helpers', '1.1' );
\Alleypack\load_module( 'fm-modules', '1.0' );
\Alleypack\load_module( 'page-templates', '1.0' );
\Alleypack\load_module( 'path-dispatch', '1.0' );
\Alleypack\load_module( 'singleton', '1.0' );
\Alleypack\load_module( 'term-post-link', '1.0' );
\Alleypack\load_module( 'unique-wp-query', '1.0' );
Expand Down
3 changes: 3 additions & 0 deletions themes/cpr/inc/rewrites.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ function rewrites() {

// Add search rewrites.
add_action( 'init', [ '\\CPR\\Components\\Templates\\Search', 'rewrite_rules' ] );

// Add additional path for newsletters to proxy through.
add_action( 'after_setup_theme', [ '\\CPR\\Components\\Templates\\Newsletter', 'dispatch_rewrites' ] );

0 comments on commit 5494edb

Please sign in to comment.