<commit_before><?php
/*
  Plugin Name: Ajax Template Part
  Plugin URI: https://github.com/Giuseppe-Mazzapica/ajax-template-part
  Description: Introduce ajax_template_part() function: like get_template_part(), but AJAX powered.
  Author: <NAME>
  Author URI: http://gm.zoomlab.it/
  License: GPLv2+
 */

/*
  Copyright (C) 2014 Giuseppe

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

register_activation_hook( __FILE__, function() {
    if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) {
        require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
    }
    $filestystem = new GM\ATP\FileSystem;
    $filestystem->getFolder();
} );


if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
    return;
}


if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) {
    require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
}


if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {

    if ( ! function_exists( 'ajax_template_part' ) ) {

        function ajax_template_part( $name, $slug = '' ) {
            GM\ATP\Templater::tag( $name, $slug );
        }

    }

    return;
}

function atp_ajax_callback() {
    $loader = new GM\ATP\Loader();
    $cache_provider = new GM\ATP\Cache\Provider();

    // no caching
    if ( ! $cache_provider->isEnabled() ) {
        $loader->getData();
        exit();
    }

    // custom object cache already installed: use that
    $transient = new GM\ATP\Cache\TransientHandler();
    if ( $transient->isAvailable() ) {
        $cache_provider->setHandler( $transient );
        $loader->setCacheProvider( $cache_provider );
        $loader->getData();
        exit();
    }
    unset( $transient );<commit_msg>Added comment on main file<commit_after><?php
/*
  Plugin Name: Ajax Template Part
  Plugin URI: https://github.com/Giuseppe-Mazzapica/ajax-template-part
  Description: Introduce ajax_template_part() function: like get_template_part(), but AJAX powered.
  Author: <NAME>
  Author URI: http://gm.zoomlab.it/
  License: GPLv2+
 */

/*
  Copyright (C) 2014 Giuseppe

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

register_activation_hook( __FILE__, function() {
    if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) {
        require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
    }
    $filestystem = new GM\ATP\FileSystem;
    $filestystem->getFolder();
} );


if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
    return;
}


if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) {
    require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
}


if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {

    if ( ! function_exists( 'ajax_template_part' ) ) {

        function ajax_template_part( $name, $slug = '' ) {
            GM\ATP\Templater::tag( $name, $slug );
        }

    }

    return;
}

function atp_ajax_callback() {
    $loader = new GM\ATP\Loader();
    $cache_provider = new GM\ATP\Cache\Provider();

    // no caching: when WP_DEBUG is true, but can be filtered via `"ajax_template_cache"`
    if ( ! $cache_provider->isEnabled() ) {
        $loader->getData();
        exit();
    }

    // custom object cache already installed: use that
    $transient = new GM\ATP\Cache\TransientHandler();
    if ( $transient->isAvailable() ) {
        $cache_provider->setHandler( $transient );
        $loader->setCacheProvider( $cache_provider );
        $loader->getData();
        exit();
    }
    unset( $transient );
{'fraction_non_alphanumeric': 0.1147439851943245, 'fraction_numerical': 0.008225375282747275, 'mean_word_length': 3.1679520137103685, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '3476476', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1499, 'n_words': 458}