Skip to content

Instantly share code, notes, and snippets.

View Neolot's full-sized avatar
🏠
Make the web great again

Yurii Pokhylko Neolot

🏠
Make the web great again
View GitHub Profile
@Neolot
Neolot / gist:6894146
Created October 9, 2013 00:24
WORDPRESS Change and Update URLS in Database When Site is Moved to new Host
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@Neolot
Neolot / gist:7189739
Last active February 28, 2023 07:06
WORDPRESS Ajax contact-form
<!-- contactform.php -->
<div class="cf" id="cf">
<form action="javascript:void(0);">
<div><input type="text" name="name" placeholder="Name"/><span class="error"></span></div>
<div><input type="text" name="email" placeholder="Email"/><span class="error"></span></div>
<div><textarea name="message" placeholder="Message"></textarea><span class="error"></span></div>
<div><button type="submit">Submit</button> <span class="loader"></span></div>
</form>
</div>
@Neolot
Neolot / gist:9327241
Last active May 16, 2018 14:31
PHP Export to csv
<?php
function array2csv(array &$array){
if (count($array) == 0) {
return null;
}
ob_start();
$df = fopen("php://output", 'w');
fputcsv($df, array_keys(reset($array)));
foreach ($array as $row) {
fputcsv($df, $row);
@Neolot
Neolot / gist:9865565
Created March 30, 2014 00:53
MODX REVO SimpleMenu
<?php
if ( $includeDocs ) {
$ids = str_replace(' ','',$includeDocs);
$ids = explode(',', $ids);
$criteria = $modx->newQuery('modResource');
$criteria->sortby('FIELD(modResource.id, '.implode(',',$ids).' )', 'ASC');
$criteria->where(array(
'id:IN' => $ids
));
@Neolot
Neolot / gist:10597184
Created April 13, 2014 18:56
WORDPRESS Remove standard image sizes
<?php
/**
* Remove standard image sizes so that these sizes are not
* created during the Media Upload process
*
* Tested with WP 3.2.1
*
* Hooked to intermediate_image_sizes_advanced filter
* See wp_generate_attachment_metadata( $attachment_id, $file ) in wp-admin/includes/image.php
*
<?php
/**
* Dimox Breadcrumbs
* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
* Since ver 1.0
* Add this to any template file by calling dimox_breadcrumbs()
* Changes: MC added taxonomy support
*/
function dimox_breadcrumbs(){
/* === OPTIONS === */
@Neolot
Neolot / gist:57515e8366f35e5601aa
Created May 10, 2014 17:12
Convert CSS to SCSS
sass-convert -F css -T scss original_file.css converted_file.scss
@Neolot
Neolot / gist:ea611da6986d7ddcbb38
Created June 30, 2014 11:27
REGEXP Удалить HTML из строки
<[^>]*>
@Neolot
Neolot / gist:345fe6999e51bb33600a
Last active October 22, 2018 14:33
LINUX Set permissions recursively
# Chown
chown user:group /path/to/base/dir -R
# For directories only
find /path/to/base/dir -type d -exec chmod 755 {} +
# For files only
find /path/to/base/dir -type f -exec chmod 644 {} +
@Neolot
Neolot / gist:8734522b3ff4393f7b96
Created August 9, 2014 16:16
JAVASCRIPT Detect browser and set class to html tag
var BrowserDetect =
{
init: function ()
{
this.browser = this.searchString(this.dataBrowser) || "Other";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
},
searchString: function (data)
{