Skip to content

Instantly share code, notes, and snippets.

@Dimasmagadan
Dimasmagadan / database encoding fix.sql
Last active December 31, 2017 12:01 — forked from ericrasch/database encoding fix.sql
Fix #WordPress database encoding issues with these #MySQL queries...source #1: http://tanyanam.com/technology/fixing-encoding-issues-on-wordpress-comments-display-as-question-markssource #2: http://stackoverflow.com/a/3568144/284091The 3 groups of repeated queries include the post content, post title, and the post slug.
ALTER DATABASE 'my_wp_database' CHARACTER SET utf8;
ALTER TABLE 'wp_comments' CHARACTER SET utf8;
alter table 'wp_comments' change comment_content comment_content LONGTEXT CHARACTER SET utf8;
alter table 'wp_comments' change comment_author comment_author LONGTEXT CHARACTER SET utf8;
update `wp_posts` set `post_content` = replace(`post_content` ,'á','á');
update `wp_posts` set `post_content` = replace(`post_content` ,'é','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'í©','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'ó','ó');
@Dimasmagadan
Dimasmagadan / admin.sql
Last active December 31, 2017 12:01
Create new admin user in #WordPress
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('5', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_user_level', '10');
function _edaeda(){
curl -v --cookie "p=aaa" https://dobripovar.ru/login/ ;
curl -v --cookie "PHPSESSID=xxx" https://dobripovar.ru/ ;
curl 'https://dobripovar.ru/index.php?route=checkout/cart/add' -H 'Host: dobripovar.ru' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'X-Requested-With: XMLHttpRequest' -H 'Referer: https://dobripovar.ru/pervie-bluda/' -H 'Cookie: PHPSESSID=xxx; language=ru; currency=RUB' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data 'product_id=74&quantity=1';
curl 'https://dobripovar.ru/index.php?route=checkout/cart/add' -H 'Host: dobripovar.ru' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0' -H 'Accept: application/json, text/javascript, */*; q=
<?php
/*
Plugin Name: MaxSite Russian Date & Russify Comments Number
Plugin URI: http://maxsite.org/
Description: Русские даты
Version: 1.0
Author: MAX & Alexander Ulizko
*/
function maxsite_the_russian_time($tdate = '') {
<?php
/**
Plugin Name: qTranslate-X Yandex Auto Translator Addon
Description: Over 900 lines of code? Rly?
Version: 1.0
Author: dimasmagadan@gmail.com
*/
/**
* undocumented function
@Dimasmagadan
Dimasmagadan / script.js
Created January 24, 2014 14:27
jQuery for WordPress
(function( $ ) {
"use strict";
$(function() {
$(document).ready(function(){
// тут код
});
// а тут плагин
});
@Dimasmagadan
Dimasmagadan / os-spam.php
Created December 12, 2013 09:48
Quick&simple anti-spam for WordPress
<?php
/*
Plugin Name: OS Spam Comments Filter
Description: antispam
Author: dimas@odminstudios.ru
Version: 1.1
*/
function verify_comment_meta_data( $commentdata ) {
@Dimasmagadan
Dimasmagadan / functions.php
Last active December 27, 2015 10:59
Yandex social share
// добавить этот код в functions.php
function os_styles_and_scripts() {
if(!is_admin()){
wp_enqueue_script( 'yashare', '//yandex.st/share/share.js', null, '1', true );
}
}
add_action( 'wp_enqueue_scripts', 'os_styles_and_scripts' );
function os_my_link_shortcode( $atts ) {
extract( shortcode_atts(
array(
'link' => '',
), $atts )
);
if(is_user_logged_in()){
$out=$link;
} else {
@Dimasmagadan
Dimasmagadan / continiue reading
Last active December 24, 2015 09:19
Scrolls to last "scroll position". Uses localStorage.
<a href="javascript:(function(){var v=&quot;1.3.2&quot;;if(window.jQuery===undefined||window.jQuery.fn.jquery&lt;v){var done=false;var script=document.createElement(&quot;script&quot;);script.src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/&quot;+v+&quot;/jquery.min.js&quot;;script.onload=script.onreadystatechange=function(){if(!done&amp;&amp;(!this.readyState||this.readyState==&quot;loaded&quot;||this.readyState==&quot;complete&quot;)){done=true;initMyBookmarklet();}};document.getElementsByTagName(&quot;head&quot;)[0].appendChild(script);}else{initMyBookmarklet();}function initMyBookmarklet(){(window.myBookmarklet=function(){jQuery(&quot;.nextProda&quot;).live(&quot;click&quot;,function(){if(typeof(localStorage)=='undefined'){alert('Ваш браузер не поддерживает localStorage()');}else{jQuery(document).scrollTop(localStorage.getItem('scroll'+encodeURIComponent(window.location.pathname)));}return false;});jQuery(&quot;body&quot;).append('&lt;a href=&quot;#&quot; class=&quot;nextProda&quot; style=&quot;back