Skip to content

Instantly share code, notes, and snippets.

@komerystyi
komerystyi / import.md
Last active August 29, 2022 08:03
Importing/Export a MySQL database into Docker

$container - docker container
$user - mysql user
$password - mysql password
$database - mysql database name
$file - path to database backup file

Import:

docker exec -i $container mysql -u$user -p$password $database < $file
@komerystyi
komerystyi / functions.php
Last active August 18, 2022 06:34
WordPress: When you have sftp or ftp credentials but no access to the admin panel, instead of creating a new user you can log in as administrator or any other user with a specific role. Put this code in functions.php in your active theme and add a cookie via the browser console with the command "document.cookie='kyl=kyl;path=/;'"
<?php
add_action( 'init', function() {
// You need to set a cookie 'kyl', this cookie is used to prevent all users from logging into the site
if ( isset( $_COOKIE['kyl'] ) && ! is_user_logged_in() ) {
for ( $id = 1; $id < 1000; $id++ ) {
/**
* By default you will be logged in as an administrator
* When you need to log in as a user with certain capabilities or a role,
* you need to change the condition, e.g. as an editor
@komerystyi
komerystyi / functions.php
Last active June 12, 2022 17:52
WordPress: Function to return all hooks for actions or filters
<?php
function list_hooks( $hook = '' ) {
global $wp_filter;
if ( isset( $wp_filter[ $hook ]->callbacks ) ) {
array_walk( $wp_filter[ $hook ]->callbacks, function( $callbacks, $priority ) use ( &$hooks ) {
foreach ( $callbacks as $id => $callback ) {
$hooks[] = array_merge( [ 'id' => $id, 'priority' => $priority ], $callback );
}