Skip to content

Instantly share code, notes, and snippets.

View sagive's full-sized avatar

Sagive SEO sagive

View GitHub Profile
@sagive
sagive / swiper-play-in-viewport.js
Last active July 2, 2022 21:37
Complete swiper example + run the swiper when it enters the viewport - treshold = "percent of element visible" -> 0.1 = 10%
// TESTIMONIALS SWIPER
const testimonySwiper = new Swiper(".testimonySwiper", {
loop: true,
slidesPerView: 1.3,
spaceBetween: 16,
centeredSlides: true,
initialSlide: 3,
autoplay: {
delay: 7500,
disableOnInteraction: true,
@sagive
sagive / Sticky-element-debugging.js
Last active July 2, 2022 21:32
this helps to find out which parent has an "overflow" settings that might cause issue with sticky.
let parent = document.querySelector('.sticky').parentElement;
while (parent) {
const hasOverflow = getComputedStyle(parent).overflow;
if (hasOverflow !== 'visible') {
console.log(hasOverflow, parent);
}
parent = parent.parentElement;
}
@sagive
sagive / wordpress-alt-tag-programmatically.php
Last active May 10, 2022 10:25
Wordpress image alt tag fixed based on image file name / title
<?php
/********************************************************
** IMAGE ALT, GLOBAL FIX
** run trough all existing images, grab the image title
** which is built using the filename automaticlly and
** asign it to the alt - at-least it wont be empty!
********************************************************/
add_action('after_setup_theme', 'image_alt_fix');
function image_alt_fix() {
$args = array(
@sagive
sagive / insert-israel-cities.php
Created April 17, 2022 17:41
Insert isael cities wordpress- הזנת ערים ואיזורים ישראל וורדפרס
<?php
/********************************************************
** INSERT CITIES WITH REGION
** insert to taxonomy named cities
********************************************************/
function insertCities() {
$cities = array(
array("ירושלים","ירושלים"),
array("תל אביב-יפו","תל אביב"),
@sagive
sagive / cf7-floating-labels-example-form.html
Last active July 24, 2023 19:04
Contact Form 7 (CF7) Floating Labels.
<div class="newsletterSignUpFooter">
<div class="form-group">[text* your-name class:form-control class:input-lg] <label for="your-name">First Name</label></div>
<div class="form-group">[text* text-777 class:form-control class:input-lg] <label for="your-name">Last Name</label></div>
<div class="form-group">[email* your-email class:form-control class:input-lg] <label for="your-name">Your Email</label></div>
<div class="">[submit class:btn class:btn-warning class:btn-lg class:w100 "Send"]</div>
</div>
@sagive
sagive / Example - Mixing it togther
Created January 20, 2015 02:09
Example - mixing it toghter
include('../functions/browser-agent.php');
include('../functions/strings.php');
include('../functions/curl-helper.php');
// ADD BROWSER EMULATION TO FILE GET CONTENT
$useragent = get_random_useragent();
// SCRAPE THE DESIRED PAGE
$clnUrl2Chk = normalize_url($urltocheck);
@sagive
sagive / Simple Curl Example
Created January 20, 2015 02:07
Simple Curl Example
function curl_download($url, $referer, $browserAgent){
if (!function_exists('curl_init')){die('Sorry cURL is not installed!');}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // Set URL to download
curl_setopt($ch, CURLOPT_REFERER, $referer); // Set a referer
curl_setopt($ch, CURLOPT_USERAGENT, $browserAgent); // User agent
curl_setopt($ch, CURLOPT_HEADER, 1); // include header?
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // print out the data?
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Timeout in seconds
@sagive
sagive / Clean url - return base url
Created January 20, 2015 01:47
Clean url - return base url
/*******************************************
** FUNCTION TO GET BASE URL
*******************************************/
function normalize_url($url) {
$parts = parse_url($url);
$countParts = count(split('[.]', $parts['host']));
if (substr($parts['host'], 0, 4) == 'www.') {
$base_url = str_replace('www.', '', $parts['host']);
}
@sagive
sagive / Get random browser agent
Last active August 29, 2015 14:13
get random browser agent
/*******************************************
** GET RANDOM USER AGENT
*******************************************/
function get_random_useragent() {
$agents = array(
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5',
'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
@sagive
sagive / gist:71ce885240ecece1311b
Created November 21, 2014 07:20
The complete style for our new login page
* {-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;}
body {background: url(images/bg-01.png) repeat 0 0;}
#login {width: 60%; max-width: 720px;}
#loginform {background: #121212;}
.message {text-align:center; background: #121212 !important; color:#fff; border: 0 !important;text-transform: uppercase;}
.login #login_error {border-top: none;background: #121212;-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);color: #DD3D36;text-align: center;font-size: 20px;font-weight: bold;text-transform: uppercase;text-shadow: 1px 1px 1px #000;}
body.login div#login h1 {height: 194px;}
body.login div#login h1 a {background: url(images/custom-login-logo.jpg) no-repeat 0 0; height: 200px; width: 768px; display: block !important; margin: 0 auto;}