Skip to content

Instantly share code, notes, and snippets.

<?php
// Callback function to format numbers with &nbsp;
function format_numbers_with_nbsp($content) {
// Regular expression pattern to match numbers
$pattern = '/\b(\d{1,3}(?:\d{3})*)\b/';
// Replace matched numbers with formatted version
$formatted_content = preg_replace_callback($pattern, 'add_nbsp_to_number', $content);
@Dimasmagadan
Dimasmagadan / WP_Query.php
Last active November 21, 2022 06:27 — forked from luetkemj/wp-query-ref.php
#WordPress query with args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
//////Author Parameters - Show posts associated with certain author.
@Dimasmagadan
Dimasmagadan / pagespeed.conf
Last active December 31, 2020 11:49
Fix for mod_pagespeed and WordPress
ModPagespeedDisallow */admin/*
ModPagespeedDisallow */wp-admin/*
ModPagespeedDisallow */tinymce/*
ModPagespeedDisallow */mysql/*
ModPagespeedDisallow */tubepress/*
@Dimasmagadan
Dimasmagadan / wp-secure.conf
Last active December 4, 2020 11:18 — forked from ethanpil/wp-secure.conf
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@Dimasmagadan
Dimasmagadan / functions.php
Last active December 31, 2017 13:04
«Поделиться» в соцсетях. #WordPress
<?php
/* подключаем скрипт */
function os_ya_like_script() {
wp_enqueue_script( 'yashare', '//yandex.st/share/share.js', null, '1', true );
}
add_action( 'wp_enqueue_scripts', 'os_ya_like_script' );
@Dimasmagadan
Dimasmagadan / WP_Comment_Query.php
Last active December 31, 2017 13:03
#WordPress Comments Query
$args = array(
'author_email' => '',
'ID' => '',
'karma' => '',
'number' => '',
'offset' => '',
'orderby' => '',
'order' => 'DESC',
'parent' => '',
'post_ID' => '',
@Dimasmagadan
Dimasmagadan / functions.php
Last active December 31, 2017 13:02
#WordPress: self expiring posts
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
$expirationtime = get_post_custom_values('expiration');
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}
$secondsbetween = strtotime($expirestring)-time();
@Dimasmagadan
Dimasmagadan / wp-config.php
Last active December 31, 2017 13:01
Отключение встроенного редактора кода и возможности установки новых плагинов #WordPress
define( 'DISALLOW_FILE_EDIT', true );
define( 'DISALLOW_FILE_MODS', true );
@Dimasmagadan
Dimasmagadan / .htaccess
Last active December 31, 2017 13:00
Rewrite for wp-content\uploads folder.To stop searching for images while working on local machine.Code to override site URL to work locally. #WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L]
</IfModule>