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 WP_Query $query | |
*/ | |
function change_rrs_posts_date( $query ) { | |
// Период обновления постов в ленте - 1 день | |
$period = 24 * HOUR_IN_SECONDS; |
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 | |
new My_Best_Metaboxes; | |
class My_Best_Metaboxes { | |
public $post_type = 'post'; | |
static $meta_key = 'company_address'; |
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 ) { |
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 | |
/** | |
* РАСПРЕДЕЛЕНИЕ ШАБЛОНОВ отображения контента в зависимости от раздела сайта | |
* Данный файл создан, чтобы хранить шаблоны в стуктурированных папках и произвольными именами, а не в корне движка | |
* | |
* @param string $template серверная ссылка к шаблону по умолчанию | |
* | |
* @return string $template серверная ссылка к пользовательскому шаблону | |
*/ | |
function jrst_tpl_path( $template ) { |
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 | |
/** | |
* Работает на основе плагина Ajax Simply (без него работать не будет). | |
* Документация Ajax Simply - https://goo.gl/iFeLsZ | |
*/ | |
// HTML верстка формы и стили | |
add_shortcode( 'form', 'contact_form_html' ); | |
function contact_form_html() { |
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_shortcode( 'subpages', 'my_subpages' ); | |
function my_subpages() { | |
$id = get_the_ID(); | |
if ( false === $id ) { | |
return ''; | |
} | |
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_filter( 'the_content', 'replace_links_to_img' ); | |
function replace_links_to_img( $content ) { | |
return preg_replace_callback( '#https?:\/\/fex\.net\/get\/[0-9]{12}\/[0-9]{9}#', function ( $match ) { | |
return "<img src=\"$match[0]\" />"; | |
}, $content ); | |
} |