Skip to content

Instantly share code, notes, and snippets.

View crizise's full-sized avatar

Kolomiitsev Olexii crizise

  • Kharkiv, Ukraine
View GitHub Profile
@crizise
crizise / wp-ajax.php
Last active October 30, 2017 22:12
Use AJAX via admin-ajax.php in Wordpress
<?php
add_action( 'wp_footer', 'my_ajax' );
function my_ajax(){
$site_url = get_site_url();
$ajax_nonce = wp_create_nonce( "my-nonce" );
?>
<script type="text/javascript">
$(document).ready(function() {
$('.item').on('click', function(e){
@crizise
crizise / post_get_content.php
Created June 17, 2017 21:08
CURL less method to get the content from the url via POST. Work over HTTP or HTTPS, second is not safe, testing purpose only.
/*
*CURL less method to get the content from the url whether it is a HTTP or HTTPS
*Not safe for HTTPS, for testing purpose only.
*Used for simple comunication with REST API.
*/
$data = array('key' => 'value');
$url = 'https://example.com/';
@crizise
crizise / function-snippet.php
Created June 17, 2017 09:35
Add custom css class to body classes. Wordpress, function.php
#Wordpress, wp-content/themes/theme-name/function.php
#Add custom css class to body classes.
add_filter( 'body_class', 'your_function');
function your_function($classes){
if(true){
return array_merge( $classes, array( 'class_name' ) );
} else{
return array_merge( $classes, array( 'other_class_name' ) );
@crizise
crizise / .htaccess
Last active August 18, 2017 13:03
Some tricks for htaccess, see description for each one
#Allow to enable redirect from http://www.example.com/ and http://example.com/ TO=====> https://www.example.com/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_SCHEME} ^http$
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
</IfModule>