Last active
December 12, 2022 23:59
-
-
Save renakdup/030aed2c3910b4ae3984dfb45c0ff838 to your computer and use it in GitHub Desktop.
Revisions
-
renakdup revised this gist
Dec 12, 2022 . 1 changed file with 81 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ <?php // Заменяет битые ссылки на кратинки в WordPress на заглушки. // Удобно, например на тестовом сайте, чтобы не переносить фотки с боевого. namespace Renak; // Инициализация if (! defined('RENAK_IMAGE_PLACEHOLDER') && RENAK_IMAGE_PLACEHOLDER === true) { add_action('init', [ImagePlaceholder::class, 'init']); } /** * Class ImagePlaceholder * Класс заполняющий отсутствующие изображения на изображения заглушки */ class ImagePlaceholder { public static function init() { add_filter('wp_get_attachment_image_src', [self::class, 'set_placeholder']); } /** * Заменяем отсутствующие изображения на заглушки * * @param array $image * * @return mixed */ public static function set_placeholder($image) { if (! $image) { return $image; } $src = $image[0]; $width = $image[1]; $height = $image[2]; // Переводим абсолютный URL в относительный путь по серверу. $path = $_SERVER['DOCUMENT_ROOT'] . wp_make_link_relative($src); if (! file_exists($path)) { $image[0] = self::get_image_placeholder($width, $height); } return $image; } /** * Получаем ссылку на изображения заглушку * * @param $width * @param $height * * @return string */ public static function get_image_placeholder($width, $height) { $images_type = [ 'animals', 'arch', 'nature', 'people', 'tech', 'any', ]; $images_filter = [ '', // without filter 'grayscale', // Черно-белые 'sepia', // Sepia ]; $image_url = "https://placeimg.com/{$width}/{$height}/" . array_rand($images_type) . '/' . array_rand($images_filter); return $image_url; } } -
renakdup revised this gist
Dec 12, 2022 . 1 changed file with 43 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ <?php // Wordpress Disable Comments (add to function.php) add_action('admin_init', function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === 'edit-comments.php') { wp_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); // Disable support for comments and trackbacks in post types foreach (get_post_types() as $post_type) { if (post_type_supports($post_type, 'comments')) { remove_post_type_support($post_type, 'comments'); remove_post_type_support($post_type, 'trackbacks'); } } }); // Close comments on the front-end add_filter('comments_open', '__return_false', 20, 2); add_filter('pings_open', '__return_false', 20, 2); // Hide existing comments add_filter('comments_array', '__return_empty_array', 10, 2); // Remove comments page in menu add_action('admin_menu', function () { remove_menu_page('edit-comments.php'); }); // Remove comments links from admin bar add_action('init', function () { if (is_admin_bar_showing()) { remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); } }); -
renakdup revised this gist
Dec 12, 2022 . No changes.There are no files selected for viewing
-
renakdup revised this gist
May 25, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php /** * Функция для замены ссылки на папку UPLOADS для localhost **/ -
renakdup renamed this gist
May 25, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
renakdup revised this gist
May 25, 2018 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ /** * Функция для замены ссылки на папку 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' ); -
renakdup revised this gist
Dec 12, 2017 . 1 changed file with 3 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,6 @@ <?php //Pagination navigation for archives of posts function rs_pagination( $wp_query = false, $query_var = 'paged', $anchor_link = '' ) { if ( ! $wp_query ) { global $wp_query; -
renakdup revised this gist
Dec 12, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,12 @@ <?php /** * Pagination navigation for archives of posts * * @param bool $ wp_query * @param string $ query_var * @param bool $ anchor_link Anchor for links * * @return array | mixed | string | void */ function rs_pagination( $wp_query = false, $query_var = 'paged', $anchor_link = '' ) { if ( ! $wp_query ) { global $wp_query; -
renakdup revised this gist
Nov 3, 2017 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,12 @@ <?php /** * Pagination navigation for archives of posts * * @param bool $ wp_query * @param string $ query_var * @param bool $ anchor_link Anchor for links * * @return array | mixed | string | void * / function rs_pagination( $wp_query = false, $query_var = 'paged', $anchor_link = '' ) { if ( ! $wp_query ) { global $wp_query; -
renakdup revised this gist
Nov 3, 2017 . 1 changed file with 41 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ <?php /** * Постраничная навигация для архивов постов * * @param bool $wp_query * @param string $query_var * @param bool $anchor_link Якорь для ссылок * * @return array|mixed|string|void */ 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; } -
renakdup revised this gist
Nov 3, 2017 . 2 changed files with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ <?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 ); File renamed without changes. -
renakdup revised this gist
Nov 3, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ <?php /** * Function substr the excerpt by type. * * @param $type string Type for substr string. -
renakdup created this gist
Nov 3, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ /** * 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; }