<commit_before><?php
/*
Plugin Name: HabitFree Accountability
Description: Keeps people accountable.
Author: <NAME>
Version: 1.0
Author URI: http://NathanArthur.com/
*/
if ( !defined( 'ABSPATH' ) ) {
    exit;
}

register_activation_hook( __FILE__, "hfActivate" );
register_deactivation_hook( __FILE__, "hfDeactivate" );

function hfActivate() {
    $Factory = new HfFactory();

    $Database    = $Factory->makeDatabase();
    $UserManager = $Factory->makeUserManager();

    wp_clear_scheduled_hook( 'hfEmailCronHook' );
    wp_schedule_event( time(), 'daily', 'hfEmailCronHook' );

    $Database->installDb();

    add_action( 'wp_loaded', array( $UserManager, 'processAllUsers' ) );

    error_log( "my plugin activated", 0 );
}

function hfDeactivate() {
    wp_clear_scheduled_hook( 'hfEmailCronHook' );
}


function hfAutoload( $folder ) {
    foreach ( scandir( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $folder ) as $filename ) {
        $path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename;
        if ( is_file( $path ) ) {
            require_once $path;
        }
    }
}

hfAutoload( 'interfaces' );
hfAutoload( 'abstractClasses' );
hfAutoload( 'classes' );

date_default_timezone_set( 'America/Chicago' );

$HfFactory               = new HfFactory();
$HfGoals                 = $HfFactory->makeGoals();
$HfUserManager           = $HfFactory->makeUserManager();
$HfAdminPanel            = $HfFactory->makeAdminPanel();
$HfAuthenticateShortcode = $HfFactory->makeAuthenticateShortcode();

add_action( 'after_setup_theme', array( $HfAuthenticateShortcode, 'attemptLogin' ) );
add_action( 'hfEmailCronHook', array( $HfGoals, 'sendReportRequestEmails' ) );
add_action( 'user_register', array( $HfUserManager, 'processNewUser' ) );
add_action( 'admin_menu', array( $HfAdminPanel, 'registerAdminPanel' ) );
add_action( 'admin_head', array( $HfAdminPanel, 'addToAdminHead' ) );
add_action( 'init', 'hfRegisterShortcodes' );
add_action( 'init', 'hfAddPostTypes' );

add_filter( 'user_can_richedit', 'hfDisableWysiwygForQuotes' );
add_filter( 'enter_title_here', 'hfChangeEditTitleLabelForQuotations' );

function hfRegisterShortcodes() {
    $Factory                 = new HfFactory();
    $SettingsShortcode       = $Factory->makeSettingsShortcode();
    $GoalsShortcode          = $Factory->makeGoalsShortcode();
    $AuthenticateShortcode   = $Factory->makeAuthenticateShortcode();
    $UserButtonsShortcode    = $Factory->makeUserButtonsShortcode();
    $InvitePartnerShortcode  = $Factory->makeInvitePartnerShortcode();
    $PartnerListShortcode    = $Factory->makePartnerListShortcode();
    $ManagePartnersShortcode = $Factory->makeManagePartnersShortcode();

    add_shortcode( 'hfSettings', array( $SettingsShortcode, 'getOutput' ) );
    add_shortcode( 'hfGoals', array( $GoalsShortcode, 'getOutput' ) );
    add_shortcode( 'hfUserButtons', array( $UserButtonsShortcode, 'getOutput' ) );
    add_shortcode( 'hfAuthenticate', array( $AuthenticateShortcode, 'getOutput' ) );
    add_shortcode( 'hfInvitePartner', array( $InvitePartnerShortcode, 'getOutput' ) );
    add_shortcode( 'hfPartnerList', array( $PartnerListShortcode, 'getOutput' ) );
    add_shortcode( 'hfManagePartners', array( $ManagePartnersShortcode, 'getOutput' ) );
}

function hfAddPostTypes() {
    register_post_type( 'hf_quotation',
        array(
            'labels'      => array(
                'name'              => __( 'Quotations' ),
                'singular_name'     => __( 'Quotation' ),
                'menu_name'         => __( 'Quotations', 'text_domain' ),
                'parent_item_colon' => __( 'Parent Quotation:', 'text_domain' ),
                'all_items'         => __( 'All Quotations', 'text_domain' ),
                'view_item'         => __( 'View Quotation', 'text_domain' ),
                'add_new_item'      => __( 'Add New Quotation', 'text_domain' ),
                'edit_item'         => __( 'Edit Quotation', 'text_domain' ),
                'update_item'       => __( 'Update Quotation', 'text_domain' ),
                'search_items'      => __( 'Search Quotation', 'text_domain' )
            ),
            'public'      => true,
            'has_archive' => true,
        )
    );

    register_taxonomy(
        'hfContext',
        'hf_quotation',
        array(
            'label'        => __( 'Context' ),
            'rewrite'      => array( 'slug' => 'context' ),
            'hierarchical' => true,
            'capabilities' => array(
                'manage_terms' => 'noone',
                'edit_terms'   => 'noone',
                'delete_terms' => 'noone',
                'assign_terms' => 'edit_posts'
            )
        )
    );

    $taxonomy = 'hfContext';

    wp_insert_term( 'For Success', $taxonomy, $args = array() );
    wp_insert_term( 'For Setback', $taxonomy, $args = array() );
    wp_insert_term( 'For Mentor', $taxonomy, $args = array() );
}

function hfDisableWysiwygForQuotes( $default ) {
    global $post;
    if ( 'hf_quotation' == get_post_type( $post ) ) {
        return false;
    }

    return $default;
}

function hfChangeEditTitleLabelForQuotations( $title ) {
    $screen = get_current_screen();

    if ( 'hf_quotation' == $screen->post_type ) {
        $title = 'Enter source / reference here';
    }

    return $title;
}<commit_msg>changed hook for processAllUsers from wp_loaded to shutdown<commit_after><?php
/*
Plugin Name: HabitFree Accountability
Description: Keeps people accountable.
Author: <NAME>
Version: 1.0
Author URI: http://NathanArthur.com/
*/
if ( !defined( 'ABSPATH' ) ) {
    exit;
}

register_activation_hook( __FILE__, "hfActivate" );
register_deactivation_hook( __FILE__, "hfDeactivate" );

function hfActivate() {
    $Factory = new HfFactory();

    $Database    = $Factory->makeDatabase();
    $UserManager = $Factory->makeUserManager();

    wp_clear_scheduled_hook( 'hfEmailCronHook' );
    wp_schedule_event( time(), 'daily', 'hfEmailCronHook' );

    $Database->installDb();

    add_action( 'shutdown', array( $UserManager, 'processAllUsers' ) );

    error_log( "my plugin activated", 0 );
}

function hfDeactivate() {
    wp_clear_scheduled_hook( 'hfEmailCronHook' );
}


function hfAutoload( $folder ) {
    foreach ( scandir( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $folder ) as $filename ) {
        $path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $filename;
        if ( is_file( $path ) ) {
            require_once $path;
        }
    }
}

hfAutoload( 'interfaces' );
hfAutoload( 'abstractClasses' );
hfAutoload( 'classes' );

date_default_timezone_set( 'America/Chicago' );

$HfFactory               = new HfFactory();
$HfGoals                 = $HfFactory->makeGoals();
$HfUserManager           = $HfFactory->makeUserManager();
$HfAdminPanel            = $HfFactory->makeAdminPanel();
$HfAuthenticateShortcode = $HfFactory->makeAuthenticateShortcode();

add_action( 'after_setup_theme', array( $HfAuthenticateShortcode, 'attemptLogin' ) );
add_action( 'hfEmailCronHook', array( $HfGoals, 'sendReportRequestEmails' ) );
add_action( 'user_register', array( $HfUserManager, 'processNewUser' ) );
add_action( 'admin_menu', array( $HfAdminPanel, 'registerAdminPanel' ) );
add_action( 'admin_head', array( $HfAdminPanel, 'addToAdminHead' ) );
add_action( 'init', 'hfRegisterShortcodes' );
add_action( 'init', 'hfAddPostTypes' );

add_filter( 'user_can_richedit', 'hfDisableWysiwygForQuotes' );
add_filter( 'enter_title_here', 'hfChangeEditTitleLabelForQuotations' );

function hfRegisterShortcodes() {
    $Factory                 = new HfFactory();
    $SettingsShortcode       = $Factory->makeSettingsShortcode();
    $GoalsShortcode          = $Factory->makeGoalsShortcode();
    $AuthenticateShortcode   = $Factory->makeAuthenticateShortcode();
    $UserButtonsShortcode    = $Factory->makeUserButtonsShortcode();
    $InvitePartnerShortcode  = $Factory->makeInvitePartnerShortcode();
    $PartnerListShortcode    = $Factory->makePartnerListShortcode();
    $ManagePartnersShortcode = $Factory->makeManagePartnersShortcode();

    add_shortcode( 'hfSettings', array( $SettingsShortcode, 'getOutput' ) );
    add_shortcode( 'hfGoals', array( $GoalsShortcode, 'getOutput' ) );
    add_shortcode( 'hfUserButtons', array( $UserButtonsShortcode, 'getOutput' ) );
    add_shortcode( 'hfAuthenticate', array( $AuthenticateShortcode, 'getOutput' ) );
    add_shortcode( 'hfInvitePartner', array( $InvitePartnerShortcode, 'getOutput' ) );
    add_shortcode( 'hfPartnerList', array( $PartnerListShortcode, 'getOutput' ) );
    add_shortcode( 'hfManagePartners', array( $ManagePartnersShortcode, 'getOutput' ) );
}

function hfAddPostTypes() {
    register_post_type( 'hf_quotation',
        array(
            'labels'      => array(
                'name'              => __( 'Quotations' ),
                'singular_name'     => __( 'Quotation' ),
                'menu_name'         => __( 'Quotations', 'text_domain' ),
                'parent_item_colon' => __( 'Parent Quotation:', 'text_domain' ),
                'all_items'         => __( 'All Quotations', 'text_domain' ),
                'view_item'         => __( 'View Quotation', 'text_domain' ),
                'add_new_item'      => __( 'Add New Quotation', 'text_domain' ),
                'edit_item'         => __( 'Edit Quotation', 'text_domain' ),
                'update_item'       => __( 'Update Quotation', 'text_domain' ),
                'search_items'      => __( 'Search Quotation', 'text_domain' )
            ),
            'public'      => true,
            'has_archive' => true,
        )
    );

    register_taxonomy(
        'hfContext',
        'hf_quotation',
        array(
            'label'        => __( 'Context' ),
            'rewrite'      => array( 'slug' => 'context' ),
            'hierarchical' => true,
            'capabilities' => array(
                'manage_terms' => 'noone',
                'edit_terms'   => 'noone',
                'delete_terms' => 'noone',
                'assign_terms' => 'edit_posts'
            )
        )
    );

    $taxonomy = 'hfContext';

    wp_insert_term( 'For Success', $taxonomy, $args = array() );
    wp_insert_term( 'For Setback', $taxonomy, $args = array() );
    wp_insert_term( 'For Mentor', $taxonomy, $args = array() );
}

function hfDisableWysiwygForQuotes( $default ) {
    global $post;
    if ( 'hf_quotation' == get_post_type( $post ) ) {
        return false;
    }

    return $default;
}

function hfChangeEditTitleLabelForQuotations( $title ) {
    $screen = get_current_screen();

    if ( 'hf_quotation' == $screen->post_type ) {
        $title = 'Enter source / reference here';
    }

    return $title;
}
{'fraction_non_alphanumeric': 0.1410149364505056, 'fraction_numerical': 0.0005566379070414695, 'mean_word_length': 3.0709969788519635, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 79, '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': '7447775', 'n_tokens_mistral': 3488, 'n_tokens_neox': 3443, 'n_words': 619}