Skip to content

Commit f63f066

Browse files
committed
Replace Settings_API Tom Select enqueue with direct registration in metabox
1 parent 99d3c4b commit f63f066

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

includes/admin/class-metabox.php

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,50 @@ public static function admin_enqueue_scripts() {
499499
WZ_CRP_VERSION
500500
);
501501

502-
// Enqueue Tom Select using Settings_API method.
503-
\WebberZone\Contextual_Related_Posts\Admin\Settings\Settings_API::enqueue_scripts_styles(
504-
'crp',
502+
if ( ! wp_style_is( 'wz-crp-tom-select', 'registered' ) ) {
503+
wp_register_style(
504+
'wz-crp-tom-select',
505+
plugins_url( 'settings/css/tom-select.min.css', __FILE__ ),
506+
array(),
507+
\WebberZone\Contextual_Related_Posts\Admin\Settings\Settings_API::VERSION
508+
);
509+
}
510+
511+
if ( ! wp_script_is( 'wz-crp-tom-select', 'registered' ) ) {
512+
wp_register_script(
513+
'wz-crp-tom-select',
514+
plugins_url( 'settings/js/tom-select.complete.min.js', __FILE__ ),
515+
array( 'jquery' ),
516+
\WebberZone\Contextual_Related_Posts\Admin\Settings\Settings_API::VERSION,
517+
true
518+
);
519+
}
520+
521+
if ( ! wp_script_is( 'wz-crp-tom-select-init', 'registered' ) ) {
522+
wp_register_script(
523+
'wz-crp-tom-select-init',
524+
plugins_url( "settings/js/tom-select-init{$file_prefix}.js", __FILE__ ),
525+
array( 'jquery', 'wz-crp-tom-select' ),
526+
\WebberZone\Contextual_Related_Posts\Admin\Settings\Settings_API::VERSION,
527+
true
528+
);
529+
}
530+
531+
wp_localize_script(
532+
'wz-crp-tom-select-init',
533+
'WZTomSelectSettings',
505534
array(
506-
'strings' => array(
535+
'endpoint' => 'category',
536+
'strings' => array(
507537
/* translators: %s: search term */
508538
'no_results' => esc_html__( 'No results found for "%s"', 'contextual-related-posts' ),
509539
),
510540
)
511541
);
542+
543+
wp_enqueue_style( 'wz-crp-tom-select' );
544+
wp_enqueue_script( 'wz-crp-tom-select' );
545+
wp_enqueue_script( 'wz-crp-tom-select-init' );
512546
}
513547
}
514548
}

0 commit comments

Comments
 (0)