Skip to content

Instantly share code, notes, and snippets.

View aiiddqd's full-sized avatar
💻
Code is poetry...

Antony I aiiddqd

💻
Code is poetry...
View GitHub Profile
@aiiddqd
aiiddqd / php
Created November 14, 2017 19:15
Use HTTPS for some sites of network
<?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);
@aiiddqd
aiiddqd / gutenberg_disable_cpt.php
Last active May 25, 2018 05:37
Disable Gutenberg support for CPT 'product' in WooCommerce
<?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 );
@aiiddqd
aiiddqd / snippet.php
Created December 18, 2017 09:31
If isset cookie - clear value and redirect to url - WordPress.
<?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);
@aiiddqd
aiiddqd / ex-amocrm-api-wrapper-wp.php
Last active January 28, 2018 18:30
ex-amocrm-api-wrapper-wp
<?php
/**
* Request wrapper for API AmoCRM
*/
function wooac_request($ep = '', $method = 'GET', $data = array())
{
try {
$cookies = get_transient('wooac_cookies');
<?php
/**
* AmoCRM API Wrapper
*/
class WooAC_API_Wrapper
{
protected $curl;
protected $url_domain;
@aiiddqd
aiiddqd / install-ioncube.sh
Created May 11, 2018 10:44 — forked from litzinger/install-ioncube.sh
Install IonCube in PuPHPet
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"
@aiiddqd
aiiddqd / correct-cookie-domain.php
Created July 8, 2018 13:34 — forked from danielbachhuber/correct-cookie-domain.php
Correct the cookie domain when a custom domain is mapped to the site.
@aiiddqd
aiiddqd / example-nginx.conf
Last active August 8, 2018 16:45 — forked from gregrickaby/example-nginx.conf
Defer the loading of images to the production/live server if file not exist - NGINX
server {
# base nginx conf
location ~ ^/wp-content/uploads/(.*) {
try_files $uri @live_uploads;
}
location @live_uploads {
@aiiddqd
aiiddqd / add-crontab-command.sh
Last active August 14, 2018 17:40
Добавляем команду запуска крона
#!/bin/bash
crontab -l | { cat; echo "*/1 * * * * curl http://site.lcl/wp-cron.php?doing_wp_cron > /dev/null 2>&1"; } | crontab -
@aiiddqd
aiiddqd / ajax-request-native.js
Created September 14, 2018 19:17
Making AJAX requests with native JavaScript
/**
* 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;