This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function datePost() { | |
$in_date = date('Y-m-d'); | |
$date = get_the_date( 'Y-m-d'); | |
$datepost = date_create(get_the_date( 'Y-m-d')); | |
date_add($datepost, date_interval_create_from_date_string('3 months')); | |
$to_date = date_format($datepost, 'Y-m-d'); | |
if( $date < $to_date && $in_date < $to_date ) | |
{ | |
echo '<span class="newcategory"></span>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Отключаем принудительную проверку новых версий WP, плагинов и темы в админке, | |
* чтобы она не тормозила, когда долго не заходил и зашел... | |
* Все проверки будут происходить незаметно через крон или при заходе на страницу: "Консоль > Обновления". | |
* | |
* @see https://wp-kama.ru/filecode/wp-includes/update.php | |
* @version 1.0 | |
*/ | |
if( is_admin() ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Function | |
* | |
* @param [string|null] $dir Directory | |
* @return mixed | |
*/ | |
function dir_to_array( $dir = null ) { | |
$result = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Автодобавление названия изображения при выборе фотки в поле названия поста | |
add_action( 'admin_print_footer_scripts', function () { | |
global $current_screen; | |
if ( 'post' == $current_screen->post_type && 'post' == $current_screen->base ) { | |
?> | |
<script> | |
jQuery(document).ready(function ($) { | |
var $titlePostInput = $('[name=post_title]'); | |
$(document).on('mouseenter', '.media-button-select', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Изменяет запрос, чтобы работала пагинация на странице category. | |
* | |
* Страница (page) category должна быть создана в админке | |
* и указана в настройках чтения, как "Страница записей" | |
* | |
* $param array $query_vars | |
* | |
* @return array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'pre_handle_404', function ( $false, $wp_query ) { | |
// если ярлык страницы содержит пробел... | |
$url = empty( $wp_query->query['pagename'] ) ? '' : $wp_query->query['pagename']; | |
if ( $url && strpos( $url, '%20' ) !== false ) { | |
$wp_query->set_404(); | |
status_header( 404 ); | |
nocache_headers(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Делает перенаправление, если открыть страницу CTP (кроме архивной) по дефолтному адресу. | |
if ( preg_match( '~/services/.+~', $_SERVER[ 'REQUEST_URI' ] ) ) { | |
$url = str_replace( '/services/', '/', $_SERVER[ 'REQUEST_URI' ] ); | |
wp_redirect( $url, 301 ); | |
exit(); | |
} | |
add_filter( 'post_type_link', 'cpt_service_remove_slug', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Simple Ajax Form | |
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
Description: A brief description of the Plugin. | |
Version: 1.0 | |
Author: campusboy | |
Author https://wp-plus.ru | |
License: MIT | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Добавляем стили в админку для ACF | |
* Добавляем функцию создание быстрых ссылок для вкладок на странице редактирования групп полей | |
*/ | |
add_action( 'current_screen', function( $current_screen ) { | |
if ( 'acf-field-group' == $current_screen->post_type && 'post' == $current_screen->base ) { | |
add_action( 'admin_head', 'acf_add_quick_tabs' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Проверяет наличие метаполя поста с заданным занчением | |
* | |
* @param string $url уникальное значение для поста, к примеру путь будет url спаршенной статьи | |
* | |
* @return bool | |
*/ | |
function is_unique_meta_parse_post( $url ) { |
OlderNewer