Skip to content

Instantly share code, notes, and snippets.

View arturmamedov's full-sized avatar
💭
code, learn, sleep, repeat

Artur arturmamedov

💭
code, learn, sleep, repeat
View GitHub Profile
<?php
$gallery_loop = false;
$the_content = get_the_content(); // all content
$galleries = []; //Create empty figures array that will hold all of our parsed HTML data
while ($gallery_loop) {
$gallery = $the_content; // <figure .. </figure>
//<!-- wp:gallery {"ids":[742,739,737],"linkTo":"none"} -->
$cut_from = '<!-- wp:gallery';
@arturmamedov
arturmamedov / simple-entire-request-cache.php
Last active April 13, 2021 14:30
Create a entire request cache file and serve it instead of exucete all code each time (also in my CMS i add an webhook/event that open url /cache/clear-all for clear all cache when i update data)
<?php
$url = $_SERVER["REQUEST_URI"];
// clear all cache
if ($url == '/cache/clear-all') {
array_map('unlink', glob("cache/*.html"));
exit('Cache clear successfully!');
}
@arturmamedov
arturmamedov / w-global-tools.js
Last active July 28, 2020 07:16
Tools that change global behavior of website things, for not deal with a lot of changes for a little thing
/**
In example make all images of website content (maybe insterted trough editor)
openable trough gallery
[this work with Blueimp Gallery https://github.com/blueimp/Gallery]
*/
$(".auto-gallery-content").each(function(){
var data_gallery = $(this).data("autoGallery") ? $(this).data("autoGallery") : "gallery";
$("img", $(this)).each(function () {
if (!$(this).hasClass('no-auto-gallery')) {
@arturmamedov
arturmamedov / w-whatsapp.js
Created May 16, 2019 12:29
WhatsApp Api on Mobile and Desktop
/**
* Replace mobile URL of WhatsApp with Desktop
* The mobile first strategy is used cause most people decide to not show WhatsApp on Desktop but only on mobile where it is very useful
*
* @dependencies [ core/w-ismobile.js ]
*/
if(withOptions.whatsappWeb && !jQuery.browser.mobile && $(".whatsapp-weburl").length > 0){
clog('WhatsApp Enabled and Present');
clog($(".whatsapp-weburl"));
@arturmamedov
arturmamedov / bootstrap4-media-breakpoints.css
Last active February 23, 2024 14:20 — forked from withArtur/bootstrap4-media-breakpoints.css
Bootstrap 4 all media query breakpoints (xs,sm,md,lg,xl) up to, down from, only
/**
* Bootstrap 4 all media queries #wMQ
* https://getbootstrap.com/docs/4.5/layout/overview/
* up > sm, md, lg, xl
* down < sm, md, lg
* only = xs, sm, lg, xl
* between <> sm-lg, sm-xl, md-xl
*/
/**
* You also can find
* Improved version and documentation
* on repository: https://github.com/arturmamedov/utm_referral-cookie
*/
// configuration
var $hostname = '.sviluppo1.loc',
cookie_params = ['source', 'medium', 'campaign']; // there are also [... 'term', 'content'] !commented
@arturmamedov
arturmamedov / ga_referrer-analytics.js
Created January 30, 2019 15:39
Google Analytics (analytics.js) get referral `ga_referrer`
ga(function(tracker) {
var ga_refferer = tracker.get('referrer'); // this get the referral from google analytics.js
if (typeof wCookies != 'undefined' && typeof wCookies().get('ga_refferer') == 'undefined') {
if (typeof ga_refferer != 'undefined') {
wCookies().set('ga_refferer', ga_refferer, {expires: 30});
} else {
wCookies().set('ga_refferer', 'direct', {expires: 30});
}
/**
* jQuery.browser.mobile (http://detectmobilebrowser.com/)
*
* jQuery.browser.mobile will be true if the browser is a mobile device
*
**/
(function (a) {
(jQuery.browser = jQuery.browser || {}).mobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(
@arturmamedov
arturmamedov / standalonepopup.html
Last active May 10, 2023 08:25
elFinder standalonepopup in a new browser window (not modal, colorbox etc.)
<!-- main.html (html input and js for open new window with elFinder for select file) -->
<input type="text" class="form-control" value="" id="idOfInput" onfocus="return openElFinder(event, 'idOfInput');"/>
<script>
$( document ).ready(function() {
window.input_id = '';
window.openElFinder = function (event, input_id) {
event.preventDefault();
window.single = true;
@arturmamedov
arturmamedov / laravel_db_to_excel.php
Created February 14, 2018 08:57
Select Eloqeunt models, filter it and transfrom for export in xls with custom format to
<?php
// refer for this gist for first steps that are trhe same: https://gist.github.com/arturmamedov/0b2e5b7e39c7e1de8fc09f69f79db618
$parent_id = '1';
// select all children sites
$sites = Site::where('parent_id', $parent_id)->get();
//dd($sites);
$children_id = $sites->pluck('id');
//dd($children_id);