Instantly share code, notes, and snippets.

View ajax-request-native.js
/**
* Get data from a URL
* @param {String} url The URL to get
* @param {Function} success Callback to run on success
* @param {Function} error Callback to run on error
*/
var getURL = function ( url, success, error ) {
// Feature detection
if ( !window.XMLHttpRequest ) return;
View add-crontab-command.sh
#!/bin/bash
crontab -l | { cat; echo "*/1 * * * * curl http://site.lcl/wp-cron.php?doing_wp_cron > /dev/null 2>&1"; } | crontab -
View example-nginx.conf
server {
# base nginx conf
location ~ ^/wp-content/uploads/(.*) {
try_files $uri @live_uploads;
}
location @live_uploads {
View correct-cookie-domain.php
View install-ioncube.sh
echo "Loading ioncube"
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
echo "Unzipping ioncube"
tar xvfz ioncube_loaders_lin_x86-64.tar.gz
echo "Move ioncube to usr/local"
mv ioncube /usr/local
echo "Add ioncube to php.ini"
sudo sed -i 1i"zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so" /etc/php5/fpm/conf.d/zzzz_custom.ini
sudo sed -i 1i"zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so" /etc/php5/cli/conf.d/zzzz_custom.ini
echo "Restarting Apache and FPM"
View amocrm_kostyl
<?php
/**
* AmoCRM API Wrapper
*/
class WooAC_API_Wrapper
{
protected $curl;
protected $url_domain;
View ex-amocrm-api-wrapper-wp.php
<?php
/**
* Request wrapper for API AmoCRM
*/
function wooac_request($ep = '', $method = 'GET', $data = array())
{
try {
$cookies = get_transient('wooac_cookies');
View snippet.php
<?php
/**
* If isset cookie - clear value and redirect to url
*/
function redirect_after_signin(){
if(is_user_logged_in()){
if( ! empty($_COOKIE["redirect_url_sso"])){
$url = $_COOKIE["redirect_url_sso"];
setcookie("redirect_url_sso", "", time() - 3600);
View gutenberg_disable_cpt.php
<?php
/*
Plugin Name: Gutenberg - disable CPT
Description: Отключаем поддержку Gutenberg для постов типа Продукт
Author: uptimizt
Version: 1.0
Author URI: http://wpcraft.ru
*/
// Use hook return apply_filters( 'gutenberg_can_edit_post_type', $can_edit, $post_type );
View php
<?php
/**
* Use HTTPS for some sites of network
*/
function rsssl_check_protocol_multisite($url, $scheme, $orig_scheme){
if(get_current_blog_id() == 23){
$url = str_replace("http://", "https://", $url);