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 / functions.php
Last active October 1, 2019 10:11
[Wordpress Yoast remove page in canonical] #seo #yoasy #wordpress
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_home_url_slash' );
function yoast_seo_canonical_change_home_url_slash( $canonical_url ) {
$re = '/\/page\/\d+\//m';
$str = $canonical_url;
$subst = '/';
$result = preg_replace($re, $subst, $str);
return $result;
}
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created April 26, 2019 05:45
[ wordpress remove feed] #wordpress #seo
<?php
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
add_action('do_feed_atom', 'itsme_disable_feed', 1);
add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1);
add_action('do_feed_atom_comments', 'itsme_disable_feed', 1);
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
@RiodeJaneiroo
RiodeJaneiroo / archive.php
Last active May 3, 2019 08:37
[Wordrepss Breadcrumbs JSON-LD] JSON-LD breadcrumbs #php #seo #wordpress #breadcrumbs
<?php
$cur_cat = get_term_by('id', get_query_var('cat'), 'category');
?>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement":
[
@RiodeJaneiroo
RiodeJaneiroo / manufacturer.php
Last active April 29, 2019 12:36
[OpenCart 2.x Шаблонные title, descr] #opencart #seo
// catalog/controller/product/manufacturer.php
// start
if ($manufacturer_info['meta_title'] && mb_strtolower($manufacturer_info['meta_title']) != mb_strtolower($manufacturer_info['name'])) {
$this->document->setTitle($manufacturer_info['meta_title']);
} else {
$productTitle = $manufacturer_info['name'] . ' в Украине и Киеве купить в интернет магазине — Choco-Yummy';
$this->document->setTitle($productTitle);
}
if($manufacturer_info['meta_description'] && strlen($manufacturer_info['meta_description']) > 60) {
$this->document->setDescription($manufacturer_info['meta_description']);
@RiodeJaneiroo
RiodeJaneiroo / category.php
Last active May 3, 2024 12:52
[Opencart filter Mega Pro] #seo #pattern #opencart #filter #megaPro #Mega Filter PRO
<?php
// don't forget: $this->load->model('catalog/manufacturer');
$pageNumber = '';
if (isset($this->request->get['page'])) {
$pageNumber = ' - Страница ' . $this->request->get['page'];
}
if(isset($this->request->get['mfp'])) { // get manufacturer name
$filterMega = $this->request->get['mfp'];
$filterMegaName = '';
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Last active June 11, 2020 13:40
[Wordpress SEO redirect from any symbol ] 301 redirect from wrong url #seo #yoast #wordpress #redirect
function wrong_url_redirect($url) {
global $wp;
if(!get_query_var('paged') && !empty($url) && !is_front_page() && $url != home_url($wp->request . '/' ) && !is_search()) {
wp_safe_redirect( $url, 301 );
exit;
}
return $url;
}
add_filter( 'wpseo_canonical', 'wrong_url_redirect' );
@RiodeJaneiroo
RiodeJaneiroo / index.html
Created May 24, 2019 14:06
[Color range] #css #color #range #scale
<div class="textarea-lineup"><span></span></div>
<script>
colorScale($('.textarea-lineup'), 10);
</script>
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created July 31, 2019 07:51
[Изменить текст опции товара] #wc #wocommerce #wordpress
<?php
add_filter('woocommerce_dropdown_variation_attribute_options_args', 'my_change_choose_an_option_text_func', 10, 2);
function my_change_choose_an_option_text_func($args){
if($args['attribute'] == 'pa_tsvet') {
$args['show_option_none'] = 'Выбрать цвет';
}
return $args;
}
@RiodeJaneiroo
RiodeJaneiroo / index.js
Created August 10, 2019 19:52
[Get Google Page Speed Score] PageSpeed Insights API
var url = 'artzm.space';
var url = (!url.match(/^[a-zA-Z]+:\/\//)) ? 'http://' + url : url;
// Google Page Speed
jQuery.ajax({
url: "https://www.googleapis.com/pagespeedonline/v5/runPagespeed",
type: "GET",
data: {
"strategy": "desktop", // or mobile
"fields": "lighthouseResult/categories/*/score",
@RiodeJaneiroo
RiodeJaneiroo / functions.php
Created August 11, 2019 08:04
[Удалить ссылку на саму себя из меню] #wordpress #seo
<?php
function yourstheme_menu_link_attributes( $args ) {
global $wp;
$current_url = untrailingslashit(add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ) );
$href = untrailingslashit( $args['href']);
if($current_url == $href){
$args['href'] = '';
}
return $args;