<commit_before><?php

/**
 * Admin class that handle ajax calls.
 */
class Papi_Admin_Ajax {

	/**
	 * The action prefix for Papi ajax actions.
	 *
	 * @var string
	 */
	protected $action_prefix = 'papi/ajax/';

	/**
	 * The construct.
	 */
	public function __construct() {
		$this->setup_actions();
	}

	/**
	 * Add ajax endpoint.
	 */
	public function add_endpoint() {
		add_rewrite_tag( '%action%', '([^/]*)' );
		add_rewrite_rule( 'papi-ajax/([^/]*)/?', 'index.php?action=$matches[1]', 'top' );
	}

	/**
	 * Add ajax url to Papi JavaScript object.
	 */
	public function ajax_url() {
		$url = esc_url( trailingslashit( get_bloginfo( 'url' ) ) . 'papi-ajax/' );
		?>
		<script type="text/javascript">
			var papi = papi || {};
			papi.ajaxUrl = '<?php echo esc_html( $url ); ?>';
		</script>
		<?php
	}

	/**
	 * Handle Papi ajax.
	 */
	public function handle_papi_ajax() {
		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			return;
		}

		$ajax_action = '';

		if ( ! empty( $_GET['action'] ) ) {
			$ajax_action = sanitize_text_field( $_GET['action'] );
		}

		if ( is_user_logged_in() && has_action( $this->action_prefix . $ajax_action ) !== false ) {
			if ( ! defined( 'DOING_AJAX' ) ) {
				define( 'DOING_AJAX', true );
			}

			if ( ! defined( 'DOING_PAPI_AJAX' ) ) {
				define( 'DOING_PAPI_AJAX', true );
			}
<commit_msg>Fix force ssl admin #213<commit_after><?php

/**
 * Admin class that handle ajax calls.
 */
class Papi_Admin_Ajax {

	/**
	 * The action prefix for Papi ajax actions.
	 *
	 * @var string
	 */
	protected $action_prefix = 'papi/ajax/';

	/**
	 * The construct.
	 */
	public function __construct() {
		$this->setup_actions();
	}

	/**
	 * Add ajax endpoint.
	 */
	public function add_endpoint() {
		add_rewrite_tag( '%action%', '([^/]*)' );
		add_rewrite_rule( 'papi-ajax/([^/]*)/?', 'index.php?action=$matches[1]', 'top' );
	}

	/**
	 * Add ajax url to Papi JavaScript object.
	 */
	public function ajax_url() {
		$url = esc_url( trailingslashit( home_url( '/' , is_ssl() ? 'https' : 'http' ) ) . 'papi-ajax/' );
		?>
		<script type="text/javascript">
			var papi = papi || {};
			papi.ajaxUrl = '<?php echo esc_html( $url ); ?>';
		</script>
		<?php
	}

	/**
	 * Handle Papi ajax.
	 */
	public function handle_papi_ajax() {
		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			return;
		}

		$ajax_action = '';

		if ( ! empty( $_GET['action'] ) ) {
			$ajax_action = sanitize_text_field( $_GET['action'] );
		}

		if ( is_user_logged_in() && has_action( $this->action_prefix . $ajax_action ) !== false ) {
			if ( ! defined( 'DOING_AJAX' ) ) {
				define( 'DOING_AJAX', true );
			}

			if ( ! defined( 'DOING_PAPI_AJAX' ) ) {
				define( 'DOING_PAPI_AJAX', true );
			}

{'fraction_non_alphanumeric': 0.19408502772643252, 'fraction_numerical': 0.0018484288354898336, 'mean_word_length': 3.0508982035928143, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2473916', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1021, 'n_words': 212}