Skip to content

Commit

Permalink
Classic Theme Helper: Copy featured content suggest js into classic t…
Browse files Browse the repository at this point in the history
…heme helper package (#37515)

* Copy featured-content related script for the classic-theme-helper package
  • Loading branch information
darssen committed May 24, 2024
1 parent 80d2ed2 commit 86d8b23
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Classic Theme Helper: Copied featured content js script from module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package automattic/jetpack
*/

use Automattic\Jetpack\Assets;

if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {

/**
Expand Down Expand Up @@ -594,7 +596,19 @@ public static function customize_register( $wp_customize ) {
* Enqueue the tag suggestion script.
*/
public static function enqueue_scripts() {
wp_enqueue_script( 'featured-content-suggest', plugins_url( 'js/suggest.js', __FILE__ ), array( 'jquery', 'suggest' ), '20131022', true );
Assets::register_script(
'featured-content-suggest',
'../build/featured-content/suggest.js',
__FILE__,
array(
'dependencies' => array(
'jquery',
'suggest',
),
'in_footer' => true,
'enqueue' => true,
)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* global ajaxurl:true */
jQuery( function ( $ ) {
$( '#customize-control-featured-content-tag-name input' ).suggest(
ajaxurl + '?action=ajax-tag-search&tax=post_tag',
{ delay: 500, minchars: 2 }
);
} );
6 changes: 3 additions & 3 deletions projects/packages/classic-theme-helper/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ const sharedWebpackConfig = {
plugins: [ ...jetpackWebpackConfig.StandardPlugins() ],
};

const responsiveVideosFiles = {};
const classicThemeHelperFiles = {};
for ( const file of glob
.sync( 'src/**/*.js' )
.filter( name => ! name.endsWith( '.min.js' ) && name.indexOf( '/test/' ) < 0 ) ) {
responsiveVideosFiles[ file.substring( 4, file.length - 3 ) ] = './' + file;
classicThemeHelperFiles[ file.substring( 4, file.length - 3 ) ] = './' + file;
}

module.exports = [
{
...sharedWebpackConfig,
entry: responsiveVideosFiles,
entry: classicThemeHelperFiles,
},
];

0 comments on commit 86d8b23

Please sign in to comment.