Wordpress
<?php
/**
* Функция для замены ссылки на папку UPLOADS для localhost
**/
function hh_replace_upload_url_path( $option ) {
global $hg_currnet_region;
if ( $_SERVER[ 'REMOTE_ADDR' ] === '127.0.0.1' ) {
return 'http://site.ru/wp-content/uploads';
}
}
add_filter( 'pre_option_upload_url_path', 'hh_replace_upload_url_path' );
<?php
//Pagination navigation for archives of posts
function rs_pagination( $wp_query = false, $query_var = 'paged', $anchor_link = '' ) {
if ( ! $wp_query ) {
global $wp_query;
}
if ( $anchor_link ) {
$anchor_link = '#' . $anchor_link;
}
$big = 999999999; // need an unlikely integer
$current = max( 1, get_query_var( $query_var ) );
$links = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) . $anchor_link ) ),
'format' => '?' . $query_var . '=%#%',
'current' => $current,
'prev_text' => '<span class="glyphicon glyphicon-menu-left"></span>Назад',
'next_text' => 'Вперед <span class="glyphicon glyphicon-menu-right"></span>',
'total' => $wp_query->max_num_pages,
) );
/*if ($current != 1) {
$links = '<a class="first page-numbers" href="' . esc_url( get_pagenum_link( 1 ) . $anchor_link ) . '"> Назад</a>' . $links;
}
if ($current != $wp_query->max_num_pages) {
$links = $links . '<a class="first page-numbers" href="' . esc_url( get_pagenum_link( $wp_query->max_num_pages ) . $anchor_link ) . '">Вперед <span class="glyphicon glyphicon-menu-right"></span></a>';
}*/
$links = str_replace( '?' . $query_var . '=1', '', $links );
return $links;
}
<?php /**
* Function substr the excerpt by type.
*
* @param $type string Type for substr string.
* @param $post post element
*/
function rs_excerpt_length( $type, $post = false ) {
if ( ! $post ) {
global $post;
}
$string = get_the_excerpt( $post );
if ( 'news' == $type ) {
if ( strlen( $string ) > 80 ) {
$string = mb_substr( $string, 0, 80, 'UTF-8' ) . '...';
}
} elseif ( 'bignews' == $type ) {
if ( strlen( $string ) > 99 ) {
$string = mb_substr( $string, 0, 99, 'UTF-8' ) . '...';
}
}
echo $string;
}
<?php // enqueues script and style
function rs_enqueues() {
wp_register_style( 'rs_bootstrap', get_template_directory_uri() . '/css/bootstrap-custom.css', false, null );
wp_enqueue_style( 'rs_bootstrap' );
wp_register_script( 'rs_masonry', get_template_directory_uri() . '/js/masonry.pkgd.js', array( 'jquery' ), '1.0.8', true );
wp_enqueue_script( 'rs_masonry' );
wp_deregister_script( 'jquery' );
wp_deregister_script( 'jquery-migrate' );
$inline_style = "
.class{
background-color: ....;
}
";
wp_add_inline_style( 'rs_main', $inline_style );
}
add_action( 'wp_enqueue_scripts', 'rs_enqueues', 100 );