Skip to content

Instantly share code, notes, and snippets.

@AlexMcowkin
AlexMcowkin / php_remove_line_breaks_and_tabulation
Last active August 29, 2015 14:18
PHP remove line breaks and tabulation
<?php
// remove line breaks
$_descr = str_replace(array("\r\n", "\r", "\n"), "", $_descr);
// remove tabulation
$_descr = preg_replace('/\t+/', '', $_descr);
// $xmlString = rtrim($xmlString, "\r\n");
// $xmlString = rtrim($xmlString, "\r");
// $xmlString = rtrim($xmlString, "\n");
@AlexMcowkin
AlexMcowkin / wp_shortcodes_with_content
Last active August 29, 2015 14:17
WP shortcodes: with content
<?php
// в посте добавить
[shortcodeName]Some content here[/shortcodeName]
// в файле functions.php
function fncName($atrs, $content)
{
$content = !empty($content) ? $content : 'No content'
//body
@AlexMcowkin
AlexMcowkin / wp_shortcodes_with_params
Last active August 29, 2015 14:17
WP shortcodes: with params
<?php
// в посте добавить
[shortcodeName user="Alex" login="Phpist85"]
// в файле functions.php
function fncName($atrs)
{
$user = isset($atrs['user']) ? $atrs['user'] : 'EmptyUser'
$login = isset($atrs['login']) ? $atrs['login'] : 'EmptyLogin'
@AlexMcowkin
AlexMcowkin / wp_protection
Created March 25, 2015 16:03
WP protection
Вы можете запретить редактирование файлов в панели администрирования с помощью константы в конфигурационном файле WordPress
wp-config.php:
define( 'DISALLOW_FILE_EDIT', true );
Учтите, что установив эту директиву вы больше не сможете устанавливать и обновлять темы и плагины через панель администратора. Вам придётся это делать вручную с помощью FTP или SSH.
define( 'DISALLOW_FILE_MODS', true );
Плагин Exploit Scanner позволит просканировать ваш WordPress на вредоносные скрипты, плагины и темы.
@AlexMcowkin
AlexMcowkin / my_git_github_list_commands
Created March 24, 2015 14:48
Git/github list commands
// ----------глобальные настроики---------
git config --global user.name "alexandr makovkin"
git config --global user.email "[email protected]"
git config --global core.editor "notepad.exe -wl1"
git config --global color.ui true
// ---------пльзовательские настроики---------
git config user.name "alexandr makovkin"
git config user.email "[email protected]"
git config core.editor "notepad.exe -wl1"
@AlexMcowkin
AlexMcowkin / php_get_full_root_path.php
Created March 20, 2015 11:28
PHP get full root path for config files
<?php
echo getcwd();
?>
/* scroll to top buttton */
a.scrollToTop{
width:75px;
height:75px;
text-align:center;
background: whiteSmoke;
text-decoration: none;
position:fixed;
bottom:30px;
right:30px;
@AlexMcowkin
AlexMcowkin / enable_js_in_browser
Last active August 29, 2015 14:17
enable JS in browser
<noscript>
Для полной работы сайта необходимо, чтоб в вашем браузере был включен JavaScript.<br />
Здесь вы найдете <a href="http://www.enable-javascript.com/" target="_blank" rel="nofollow">инструкции</a> как включить
JavaScript в вашем браузере.
</noscript>
<!--[if lt IE 8]>
<p class="browserupgrade">Вы используете <strong>старую</strong> версию баузера. Пожалуйста,
<a href="http://browsehappy.com/">обновите ваш браузер</a>.</p>
<![endif]-->
@AlexMcowkin
AlexMcowkin / wp_add_custom_template
Created March 16, 2015 15:28
WP add custom template
<?php /* Template Name: Form */ ?>
<?php get_header();?>
<div>
<!-- content here -->
</div>
<?php get_footer();?>
@AlexMcowkin
AlexMcowkin / css_responsive_image
Created March 13, 2015 16:45
css responsive image
<!-- style="max-width:100%;height:auto;" -->
<img src="motorcycle.jpg" alt="Motorcycle" style="max-width:100%;height:auto;" />