Skip to content

Instantly share code, notes, and snippets.

View amorkovin's full-sized avatar

Андрей Морковин amorkovin

View GitHub Profile
@amorkovin
amorkovin / unload_scripts_admin_wp.php
Created October 24, 2018 13:07
Отключение скриптов в админке WordpRess
add_action('admin_enqueue_scripts', 'unload_all_jquery');
function unload_all_jquery() {
$jquery_ui = array(
"jquery-ui-widget",
"jquery-ui-mouse",
"jquery-ui-core",
"jquery-ui-accordion",
"jquery-ui-autocomplete",
"jquery-ui-slider",
"jquery-ui-tabs",
@amorkovin
amorkovin / google_query_wordpress.php
Created October 25, 2018 16:24
jQuery грузит с серверов Google для WordPress
function add_styles_scripts(){
//Jquery
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', array(), null);
wp_enqueue_script('jquery');
}
add_action( 'wp_enqueue_scripts', 'add_styles_scripts' );
@amorkovin
amorkovin / media.css
Created October 26, 2018 11:54
media
@media screen and (max-width: 1023px) {
}
@amorkovin
amorkovin / menu-text.php
Created October 29, 2018 09:51
Убрать ссылку у пукнта меню с классом «menu-text»
$nav = preg_replace('%((menu-text)[^<]+)[^>]+>([^<]+)<\/a>%', '$1<span>$3</span>', $nav);
@amorkovin
amorkovin / comments_get_wp.php
Created October 30, 2018 16:00
Получение комментариев WordPress
<?php
$args = array(
'number' => 2,
'post_id' => get_the_ID(),
'orderby' => 'comment_date',
'order' => 'DESC',
'status' => 'approve',
'type' => 'comment',
);
$comments = get_comments($args);
@amorkovin
amorkovin / open_graph_wp.php
Last active November 28, 2018 19:53
Open Graph для WordPress
<?php
add_action( 'wp_head', 'morkovin_opengraph_add_head' );
function morkovin_opengraph_add_head(){
if(function_exists('show_morkovniy_opengraph')) { show_morkovniy_opengraph(); }
}
function show_morkovniy_opengraph() {
if ( is_single() ) {
$title = get_the_title();
$post = get_post( get_the_ID() );
@amorkovin
amorkovin / jquery_footer_wp.php
Created November 13, 2018 10:42
Загрузка jQuery из подвала WordPress
@amorkovin
amorkovin / async_wp.php
Created November 13, 2018 10:44
Async для скриптов WordPress
function mihdan_add_async_attribute( $tag, $handle ) {
if ( 'my-js-handle' !== $handle ) {
return $tag;
}
return str_replace( ' src', ' async="async" src', $tag );
}
add_filter( 'script_loader_tag', 'mihdan_add_async_attribute', 10, 2 );
@amorkovin
amorkovin / abc_wp.php
Last active February 5, 2020 09:58
Алфавитка для рубрики WordPress
<?php
class AbcCategory {
private $cat_id;
function __construct($cat_id) {
$this->cat_id = $cat_id;
}
public static function sorting( & $array ) {
$memory = NULL;
@amorkovin
amorkovin / recent_posts_wp_morkovin.php
Last active November 29, 2018 12:58
Свежие публикации Морковина для WP
<?php
class RecentPosts_Morkovin_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'recentpost_morkovin', // Base ID
__( 'Свежие публикации Морковина', 'text_domain' ), // Name