Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Facebook_Helpers::get_inline_js()


Source

File: src/integrations/facebook/helpers/facebook-helpers.php

	private function get_inline_js() {
		?>
		<script>
			jQuery(document).ready(function($){
				'use strict';
				var url = "<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>";
				$.ajax({
					dataType: 'json',
					url: url,
					data: {
						action: '<?php echo esc_html( "{$this->wp_ajax_action}_fetch_user_pages" ); ?>',
						nonce: '<?php echo esc_html( wp_create_nonce( self::OPTION_KEY ) ); ?>'
					},
					success: function( response ) {

						if ( 200 === response.status ) {

							var $li = "";

							$.each( response.pages, function( i, page ){

								$li += '<li>';
								$li += '<span class="uo-fb-pages-item-id">'+page.value+'</span>';
								$li += '<a href="https://facebook.com/'+page.value+'" target="_blank">' + page.text + '</a>';

								/*$.each( page.tasks, function(i, task){
									$li += '<span class="uo-fb-pages-item-task enabled">' + task + '</span>';
								});*/
								$li += '<span class="uo-fb-pages-item-task enabled"><span class="dashicons dashicons-yes"></span></span>';

								$li += '</li>';
							} );

							$('#uo-user-fb-pages').html('<ul>'+$li+'</ul>');
						} else {
							$('#uo-user-fb-pages > p').html( response.message ).addClass('error');
						}

					},
					error: function( e, message ) {
						$('#uo-user-fb-pages > p').html( message ).addClass('error');
					}
				});
			});
		</script>
		<?php
	}