Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.9 kB
2
Indexable
Never
<?php
function td_register_stylesheet() {
    wp_enqueue_style("bootstrap", get_stylesheet_directory_uri() . "/css/bootstrap.min.css");
    wp_enqueue_script("bootstrap", get_stylesheet_directory_uri() . "/js/bootstrap.min.js", array("jquery"), "1.0.0", true);
    wp_enqueue_style("td-style", get_stylesheet_directory_uri() . "/style.css");
    wp_enqueue_script("app", get_stylesheet_directory_uri() . "/js/app.js", array("jquery", "wp-api"), "1.0.0", true);
}
add_action("wp_enqueue_scripts", "td_register_stylesheet");

function td_disable_gutenberg() {
    remove_post_type_support("page", "editor");
    remove_post_type_support("post", "editor");
}
add_action("init", "td_disable_gutenberg");

function td_mark_task_as_done() {
    $doneId = $_GET["doneId"] ?? null;
    if($doneId) {
        update_post_meta($doneId, "done", get_post_meta($doneId, "done", true) == "Yes" ? "No" : "Yes");
    }
}
add_action("init", "td_mark_task_as_done");

function td_clear() {
    if(isset($_GET["clear"])) {
        $tasks = new WP_Query(array(
            "post_type" => "task",
            "posts_per_page" => -1,
            "meta_key" => "done",
            "meta_value" => "Yes",
            "post_status" => "any"
        ));

        global $post;
        while($tasks->have_posts()): 
            $tasks->the_post();
            wp_delete_post(get_the_ID(), true);
        endwhile;
    }
}
add_action("init", "td_clear");

add_filter("wpcf7_autop_or_not", "__return_false");

function polylang_translate()
{
    pll_register_string('my_tasks', 'My tasks');
    pll_register_string('add_new_task', 'Add new task');
    pll_register_string('Pomodoro_technique', 'Pomodoro technique');
    pll_register_string('Time-Boxing_technique', 'Time-Boxing technique');
    pll_register_string('Say_no', 'Say no');
    pll_register_string('Clear_completed', 'Clear completed');
}
add_action( 'init', 'polylang_translate' );