Skip to content

Instantly share code, notes, and snippets.

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 = [
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
function translations()
{
add_filter(
"get_term",
function ($term, $tax) {
if (is_admin()) {
return $term;
}
$fixes = [
@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;
add_action('init', function () {
unregister_taxonomy_for_object_type('post_tag', 'post');
//unregister_taxonomy_for_object_type('category', 'post');
});
function mb_block_renderer($attributes, $is_preview = false, $post_id = null)
{
$context = Timber::context();
$context['content'] = $attributes['data'];
$context['is_preview'] = $is_preview;
$context['post_id'] = $post_id;
Timber::render("blocks/{$attributes['name']}.twig", $context);
}
const handleClick(e){
console.log('this target has been clicked:', e.currentTarget);
}
elementsList.forEach(e => e.addEventListener('click', handleClick, false));