Skip to content

Instantly share code, notes, and snippets.

const handleClick(e){
console.log('this target has been clicked:', e.currentTarget);
}
elementsList.forEach(e => e.addEventListener('click', handleClick, false));
function mb_block_renderer($attributes, $block)
{
$context = Timber::context();
$context['attributes'] = $attributes;
$context['is_preview'] = defined('REST_REQUEST') && REST_REQUEST;
$context['post_id'] = get_the_ID();
$context['PREFIX'] = PREFIX;
$block_name = end(explode('/', $block->name));
Timber::render("blocks/{$block_name}.twig", $context);
add_action('init', function () {
unregister_taxonomy_for_object_type('post_tag', 'post');
//unregister_taxonomy_for_object_type('category', 'post');
});
@jstask82
jstask82 / limit wordpress media library to current user.php
Created October 11, 2022 16:57
you ned to disable list view for this to work, use adminimize!
add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );
function wpb_show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
//has the capability to activate plugins or edit other user’s posts? if not limit files to users id
if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
') ) {
$query['author'] = $user_id;
}
return $query;
function translations()
{
add_filter(
"get_term",
function ($term, $tax) {
if (is_admin()) {
return $term;
}
$fixes = [
function ak_disable_blocks($allowed_blocks, $post)
{
//get all blocks
$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
//list all blocks
//var_dump(array_keys($registered_blocks));
//exit();
//disable unwanted blocks
require_once ABSPATH . 'wp-admin/includes/plugin.php';
//Your Plugins here
$required_plugins = [
'Meta Box' => is_plugin_active('meta-box/meta-box.php'),
'MB Admin Columns' => is_plugin_active('mb-admin-columns/mb-admin-columns.php'),
];
//Alternative Plugins here
$required_plugins_alt = [