Skip to content

Instantly share code, notes, and snippets.

View domosedov's full-sized avatar
🏠
Working from home

Aleksandr Grigorii domosedov

🏠
Working from home
View GitHub Profile
@domosedov
domosedov / list-style.css
Created September 7, 2018 09:55
Альтернатива для list-style-image
li {
margin: 0;
padding: 10px 0 10px 20px;
list-style: none;
background-image: url();
background-repeat: no-repeat;
background-position: left center;
background-size: 20px;
}
@domosedov
domosedov / Описание таблицы.php
Created September 14, 2018 06:58
фрагмент кода, позволяющий проверить в браузере факт успешного создания таблицы
<?php
require_once 'login.php';
$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);
$query = "DESCRIBE <Имя таблиц>";
$result = $conn->query($query);
if (!$result) die ("Database access failed: " . $conn->error);
$rows = $result->num_rows;
@domosedov
domosedov / vsce.txt
Created November 28, 2018 14:34
My VS Code Extensions
Atishay-Jain.All-Autocomplete
bmewburn.vscode-intelephense-client
CoenraadS.bracket-pair-colorizer
dbaeumer.vscode-eslint
eg2.tslint
eg2.vscode-npm-script
esbenp.prettier-vscode
felixfbecker.php-debug
felixfbecker.php-intellisense
felixfbecker.php-pack
…or create a new repository on the command line
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/domosedov-dev/test.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/domosedov-dev/test.git
git push -u origin master
@domosedov
domosedov / custom-post-type-loop.php
Created March 3, 2020 16:13
custom-post-type-loop
<?php
$loop = new WP_Query( array(
'post_type' => 'Property',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
@domosedov
domosedov / find-in-acf-array.php
Created March 13, 2020 17:01
Best method I’m aware of to search in array based fields
$search_value = 'xyz'; // whatever
$field_value = sprintf( '^%1$s$|s:%2$u:"%1$s";', $search_value, strlen( $search_value ) );
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'user_field',
'value' => $field_value,
'compare' => 'REGEXP'
@domosedov
domosedov / wp.php
Created March 20, 2020 11:28
WP get custom post-type
$args = array(
'author' => get_current_user_id(),
'post_type' => 'YOUR_CUSTOMPOST_TYPE',
);
$author_posts = new WP_Query( $args );
if ($author_posts->have_posts()): while ($author_posts->have_posts()) : $author_posts->the_post();
//DISPLAY CONTENTS HERE
endwhile; endif;
@domosedov
domosedov / parcel.txt
Created May 28, 2020 10:15
Parcel CLI
parcel watch /path/to/filename.js -d /path/to/dist --public-url . (for sourcemap)
@domosedov
domosedov / formdata-to-string.js
Created June 7, 2020 12:44
Convert FormData to Query String
function handleSubmit(event) {
event.preventDefault();
const formData = new FormData(event.target);
const data = [...formData.entries()];
const asString = data
.map(x => `${encodeURIComponent(x[0])}=${encodeURIComponent(x[1])}`)
.join('&');
console.log(asString);
}
@domosedov
domosedov / .htaccess
Created June 8, 2020 20:13
For React with WP API
<IfModule mod_rewrite.c>
RewriteRule ^(api)($|/) - [L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>