Skip to content

Instantly share code, notes, and snippets.

View RiodeJaneiroo's full-sized avatar
🎯
Focusing

Vadim Zmiievskyi RiodeJaneiroo

🎯
Focusing
  • Ukraine
View GitHub Profile
@RiodeJaneiroo
RiodeJaneiroo / index.html
Last active October 15, 2019 16:33
[YouTube Iframe ] optimization
<div class="ytvideo">
<a class="ytvideo__link" href="https://youtu.be/tTHiLxPHwWo" data-id="tTHiLxPHwWo">
<picture>
<img class="ytvideo__media img lazyload" data-src="http://img.youtube.com/vi/tTHiLxPHwWo/0.jpg" alt="Отзыв">
</picture>
</a>
<button class="ytvideo__button" type="button" aria-label="Запустить видео">
<svg width="68" height="48" viewBox="0 0 68 48">
<path class="ytvideo__button-shape" d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z"></path>
<path class="ytvideo__button-icon" d="M 45,24 27,14 27,34"></path>
@RiodeJaneiroo
RiodeJaneiroo / .gitignore
Last active March 7, 2019 08:34
gitignore
node_modules/
build/
# Created by https://www.gitignore.io/api/vue,node,sass,macos,vuejs,nuxtjs,phpstorm,visualstudiocode
# Edit at https://www.gitignore.io/?templates=vue,node,sass,macos,vuejs,nuxtjs,phpstorm,visualstudiocode
### macOS ###
# General
.DS_Store
.AppleDouble
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created January 30, 2019 09:56
[Fix url] #wordpress #seo
<?php
// fix when zero in end url
add_action( 'pre_handle_404', 'fix_fake_page' );
function fix_fake_page( $false ) {
global $wp_query;
if ( is_singular()
&& isset( $wp_query->query['page'] )
&& $wp_query->query['page'] === '0'
) {
@RiodeJaneiroo
RiodeJaneiroo / method1.js
Last active March 15, 2023 17:30
[Разбить число на разряды JS] #js #javascript #number
// Method #1
var num = 1234567890;
var result = num.toLocaleString(); // or .toLocaleString('ru');
console.log(result);
// Method #2
function numberWithSpaces(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
console.log(numberWithSpaces(100));
@RiodeJaneiroo
RiodeJaneiroo / wp_remove_h1_from_editor.php
Last active February 14, 2019 10:08
Remove h1 from the WordPress editor. #wordpress
<?php
/**
* Remove the h1 tag from the WordPress editor.
*
* @param array $settings The array of editor settings
* @return array The modified edit settings
*/
function remove_h1_from_editor( $settings ) {
$settings['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre;';
return $settings;
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Last active March 26, 2019 12:01
[flexible loop ACF] #acf #wordpress #loop
function get_flexible_loop($page_id = null){
if(have_rows('flexible', $page_id)) {
while (have_rows('flexible', $page_id)) {
the_row();
$section_name = str_replace('_', '-', get_row_layout());
get_template_part("/parts/flexible/{$section_name}");
}
}
@RiodeJaneiroo
RiodeJaneiroo / function.php
Created April 4, 2019 17:19
[Wordpress ЧПУ URL] делает чпу без слагов #wordpress #redirect #cpt
<?php
add_filter('request', 'rudr_change_term_request', 1, 1 );
function rudr_change_term_request($query){
$tax_name = 'kapers'; // specify you taxonomy name here, it can be also 'category' or 'post_tag'
// Request for child terms differs, we should make an additional check
if( isset($query['attachment']) && $query['attachment']) :
@RiodeJaneiroo
RiodeJaneiroo / .htaccess
Last active April 20, 2020 13:53
[Wordpress SEO URL few slash/slesh] redirect from multiple sleshes to one #seo #wordpress #redirect #htaccess #php
RewriteCond %{THE_REQUEST} \ (.*)//+
RewriteRule (.*) https://www.kaper.pro/$1 [R=301,L]
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created April 19, 2019 09:37
[Wordpres Contact Form 7] Add custom tag in CF7 (Pure url) #cf7 #wordpress #contact_form_7
add_filter( 'wpcf7_form_elements', 'do_shortcode' );
function pure_url_cf7_func() {
$submission = WPCF7_Submission::get_instance();
$url = $submission->get_meta( 'url' );
return strtok($url, '?');
}
add_shortcode('puress_url', 'pure_url_cf7_func');
wpcf7_add_form_tag('puress_url', 'pure_url_cf7_func');
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Last active January 31, 2023 13:12
[Wordpress Default link image media] in Gutenberg set default in image link media #wp #wordpress #gutenberg
function setDefaultHrefImage() {
wp_enqueue_script(
'modify-image-link-destination-default',
get_template_directory_uri() . '/js/setDefaultHrefImage.js',
array('wp-hooks')
);
}
add_action('enqueue_block_editor_assets', 'setDefaultHrefImage');