PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
← All changes | includes/replacement/callbacks.php +22 -5 0.7.71.0.2 View file →
@@ -113,14 +113,22 @@
113 113
114 114 if ( $frontend_uri ) {
115 115 $home_url = trailingslashit( get_home_url() );
116 116 $frontend_uri = trailingslashit( $frontend_uri );
117 +
118 + $link = str_replace( $home_url, $frontend_uri, $link );
119 +
120 + // Replace the schemes, if different.
121 + $frontend_uri_scheme = wp_parse_url( $frontend_uri, PHP_URL_SCHEME );
122 + $link_scheme = wp_parse_url( $link, PHP_URL_SCHEME );
123 + if ( $frontend_uri_scheme !== $link_scheme ) {
124 + $link = str_replace( $link_scheme . '://', $frontend_uri_scheme . '://', $link );
125 + }
126 +
117 127 /**
118 128 * This should already be handled by WPE\FaustWP\Replacement\post_link, but
119 129 * it's here for verbosity's sake and if the other filter changes for any reason.
120 130 */
121 - $link = str_replace( $home_url, $frontend_uri, $link );
122 -
123 131 $parsed_link_query = wp_parse_url( $link, PHP_URL_QUERY );
124 132 $args = wp_parse_args( $parsed_link_query );
125 133 $preview_id = isset( $args['preview_id'] ) ? $args['preview_id'] : $post->ID;
126 134
@@ -129,13 +137,22 @@
129 137 array_keys( $args ),
130 138 $link
131 139 );
132 140
141 + if ( ! isset( $args['previewPathname'] ) ) {
142 + $args['previewPathname'] = rawurlencode( wp_make_link_relative( get_permalink( $post ) ) );
143 + }
144 +
133 145 // Add p=xx if it's missing, which is the case for published posts.
134 146 if ( ! isset( $args['p'] ) ) {
135 147 $args['p'] = $preview_id;
136 148 }
137 149
150 + // Add preview=true in case other plugins have stripped it.
151 + if ( ! isset( $args['preview'] ) ) {
152 + $args['preview'] = 'true';
153 + }
154 +
138 155 // Add page_id=xx if it's missing, which is the case for published pages.
139 156 if ( ! isset( $args['page_id'] ) && 'page' === $post->post_type ) {
140 157 $args['page_id'] = $preview_id;
141 158 }
@@ -167,12 +184,12 @@
167 184
168 185 return $link;
169 186 }
170 187
171 -
172 188 add_filter( 'post_link', __NAMESPACE__ . '\\post_link', 1000 );
189 +add_filter( 'page_link', __NAMESPACE__ . '\\post_link', 1000 );
173 190 /**
174 - * Callback for WordPress 'post_link' filter.
191 + * Callback for WordPress 'post_link' & 'page_link' filter.
175 192 *
176 193 * Swap post links in admin for headless front-end.
177 194 *
178 195 * @param string $link URL used for the post.
@@ -213,9 +230,9 @@
213 230 *
214 231 * XXX: Please remove this once this issue is resolved: https://github.com/WordPress/gutenberg/issues/13998
215 232 */
216 233 function enqueue_preview_scripts() {
217 - wp_enqueue_script( 'faustwp-gutenberg-filters', plugins_url( '/previewlinks.js', __FILE__ ), array(), '1.0.0', true );
234 + wp_enqueue_script( 'faustwp-gutenberg-filters', plugins_url( '/previewlinks.js', __FILE__ ), array( 'jquery' ), '1.0.0', true );
218 235 wp_localize_script( 'faustwp-gutenberg-filters', '_faustwp_preview_link', array( '_preview_link' => get_preview_post_link() ) );
219 236 }
220 237
221 238 add_filter( 'wp_sitemaps_posts_entry', __NAMESPACE__ . '\\sitemaps_posts_entry' );