Skip to content

Instantly share code, notes, and snippets.

@ivandoric
ivandoric / all.tsx
Created May 30, 2021 09:28
Infinite Scroll And Filters With React Query
import Container from "components/ui/Container"
import VideoCard from "components/VideoCard"
import fetchData from "helpers/fetchData"
import { useEffect, useState, Fragment, useRef } from "react"
import { useInfiniteQuery } from "react-query"
import useIntersectionObserver from "../hooks/useIntersectionObserver"
import Select from "react-select"
import { useUIDSeed } from "react-uid"
import { useRouter } from "next/router"
import Seo from "components/Seo"
@ivandoric
ivandoric / wl-api.php
Last active September 3, 2023 00:16
WordPress Rest API Custom Endpoints Video Tutorials Notes - Check out the videos: https://www.youtube.com/watch?v=C2twS9ArdCI and https://www.youtube.com/watch?v=76sJL9fd12Y
<?php
/**
* Plugin Name: Custom API
* Plugin URI: http://chrushingit.com
* Description: Crushing it!
* Version: 1.0
* Author: Art Vandelay
* Author URI: http://watch-learn.com
*/
@ivandoric
ivandoric / index.php
Last active May 23, 2023 19:23
WordPress Rest API Add Posts From Frontend (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=_w4Ok-lI48g
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="<?php echo get_template_directory_uri() ?>/style.css">
<title>Watch Learn Theme</title>
</head>
<body>
<h1>Hello World</h1>
@ivandoric
ivandoric / [id].jsx
Last active February 28, 2023 12:42
Code used in video - [Next + Strapi - Internationalization](https://www.youtube.com/watch?v=iqi3ZSp1cpE)
import Link from "next/link";
import { useRouter } from "next/router";
function Page({ content }) {
const router = useRouter();
console.log(router);
return (
<div className="container">
@ivandoric
ivandoric / add-movies.jsx
Last active December 19, 2022 11:22
Frontend code for adding data to Directus using Flows - video tutorial can be found here: https://www.youtube.com/watch?v=Nrg7BFOWwuc
// Check the video for more info: https://www.youtube.com/watch?v=Nrg7BFOWwuc
import React, {useEffect, useState} from 'react';
import Papa from "papaparse";
const AddMovies = () => {
const [moviesList, setMoviesList] = useState([])
const handleSubmit = (e) => {
@ivandoric
ivandoric / gulpfile.js
Last active September 18, 2022 18:14
Adding Svelte To Your Website Using Gulp and Webpack
// This is the code used in video "How To Add Svelte To Your Site?"
// Check out the video here: https://www.youtube.com/watch?v=ZL7mKFQHSAY
const gulp = require('gulp')
const sass = require('gulp-sass')
const browsersync = require('browser-sync').create()
const webpack = require('webpack')
const webpackStream = require('webpack-stream')
@ivandoric
ivandoric / .htaccess
Last active June 27, 2022 09:51
.htaccess file for video tutorial about deploying Node apps to shared hosting. Checkout the video: https://www.youtube.com/watch?v=ebWJbbUT4TA
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:8080/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:1337/$1 [P,L]
@ivandoric
ivandoric / gist:11212191
Created April 23, 2014 11:47
wordpress: WPML Custom Language switcher
<?php
/*Just add this anywhere in yopur template where you want language switcher to appear.
This switcher just shows the flags. But you can make it work anyway you like */
?>
<ul class="lang-switcher">
<?php
$languages = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str');
foreach($languages as $language){
$flag = $language['country_flag_url'];
@ivandoric
ivandoric / wl-api.php
Created October 5, 2020 09:17
WordPress Rest API Custom Filters (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=5rSfAkLO5eo
<?php
/**
* Plugin Name: Custom API
* Plugin URI: http://chrushingit.com
* Description: Crushing it!
* Version: 1.0
* Author: Art Vandelay
* Author URI: http://watch-learn.com
*/
@ivandoric
ivandoric / list.phtml
Last active March 17, 2021 22:09
magento: Check if product is new in product listing
<?php
$newFromDate = Mage::getModel('catalog/product')->load($_product->getID())->getNewsFromDate();
$newToDate = Mage::getModel('catalog/product')->load($_product->getID())->getNewsToDate();
$now = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
if(($newFromDate < $now && $newFromDate != NULL) && ($newToDate > $now || $newToDate == "")){
echo "New Product";
}
?>