HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/posts-field.js.tar
uyarreklam.com.tr/httpdocs/wp-content/plugins/so-widgets-bundle/base/inc/fields/js/posts-field.js000064400000001704151554732470032122 0ustar00var/www/vhosts/* global jQuery, soWidgets, sowbForms */

( function( $ ) {

	$( document ).on( 'sowsetupform', '.siteorigin-widget-field-type-posts', function( e ) {
		const $postsField = $( this );
		const hasCount = $postsField.find( '.sow-current-count' ).length > 0;
		const postId = parseInt( jQuery( '#post_ID' ).val() );

		if ( ! hasCount ) {
			return;
		}

		$postsField.on( 'change', function( event ) {
			var postsValues = sowbForms.getWidgetFormValues( $postsField );
			var queryObj = postsValues.hasOwnProperty( 'posts' ) ? postsValues.posts : null;

			var query = '';
			for ( var key in queryObj ) {
				if ( query !== '' ) {
					query += '&';
				}
				query += key + '=' + queryObj[ key ];
			}

			$.post(
				soWidgets.ajaxurl,
				{
					action: 'sow_get_posts_count',
					query: query,
					postId: postId,
				},
				function( data ) {
					$postsField.find( '.sow-current-count' ).text( data.posts_count );

				}
			);
		} );
	} );

} )( jQuery );