Skip to content

Commit

Permalink
Use ROOT_FILE for title ab test asset URL
Browse files Browse the repository at this point in the history
  • Loading branch information
roborourke committed Jun 5, 2020
1 parent ddc9dd0 commit e59f4fc
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions inc/features/titles/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

namespace Altis\Experiments\Features\Titles;

use function Altis\Experiments\output_ab_test_html_for_post;
use function Altis\Experiments\register_post_ab_test;
use function Altis\Experiments\Utils\get_asset_url;
use Altis\Experiments;
use Altis\Experiments\Utils;

/**
* Bootstrap Title AB Tests Feature.
Expand All @@ -25,7 +24,7 @@ function setup() {
/**
* Load Block Editor sidebar plugin.
*
* @param string $hook
* @param string $hook Page hook suffix.
*/
function admin_scripts( string $hook ) {
if ( ! in_array( $hook, [ 'post.php', 'post-new.php' ], true ) ) {
Expand All @@ -41,7 +40,7 @@ function admin_scripts( string $hook ) {

wp_enqueue_script(
'altis-experiments-features-titles',
get_asset_url( 'features/titles.js' ),
Utils\get_asset_url( 'features/titles.js' ),
[
'wp-plugins',
'wp-blocks',
Expand All @@ -62,7 +61,7 @@ function admin_scripts( string $hook ) {
'window.Altis.Analytics = window.Altis.Analytics || {};' .
'window.Altis.Analytics.Experiments = window.Altis.Analytics.Experiments || {};' .
'window.Altis.Analytics.Experiments.BuildURL = %s;',
wp_json_encode( plugins_url( 'build', dirname( __FILE__, 3 ) ) )
wp_json_encode( plugins_url( 'build', Experiments\ROOT_FILE ) )
),
'before'
);
Expand Down Expand Up @@ -97,7 +96,7 @@ function register_default_post_type_support() {
* @return string
*/
function add_title_ab_test_to_title( string $title, int $post_id ) : string {
return output_ab_test_html_for_post( 'titles', $post_id, $title );
return Experiments\output_ab_test_html_for_post( 'titles', $post_id, $title );
}

/**
Expand All @@ -108,7 +107,7 @@ function init() {
add_filter( 'the_title', __NAMESPACE__ . '\\add_title_ab_test_to_title', 10, 2 );
}

register_post_ab_test(
Experiments\register_post_ab_test(
'titles',
[
'label' => __( 'Titles', 'altis-experiments' ),
Expand Down

0 comments on commit e59f4fc

Please sign in to comment.