Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Dorić ivandoric

View GitHub Profile
@ivandoric
ivandoric / wl-api.php
Last active Nov 8, 2022
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
View wl-api.php
<?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 / all.tsx
Created May 30, 2021
Infinite Scroll And Filters With React Query
View all.tsx
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 / gulpfile.js
Last active Sep 18, 2022
Adding Svelte To Your Website Using Gulp and Webpack
View gulpfile.js
// 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 Jun 27, 2022
.htaccess file for video tutorial about deploying Node apps to shared hosting. Checkout the video: https://www.youtube.com/watch?v=ebWJbbUT4TA
View .htaccess
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 Apr 23, 2014
wordpress: WPML Custom Language switcher
View gist:11212191
<?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 Oct 5, 2020
WordPress Rest API Custom Filters (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=5rSfAkLO5eo
View wl-api.php
<?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 Jan 7, 2022
WordPress Rest API Add Posts From Frontend (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=_w4Ok-lI48g
View index.php
<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 Jun 6, 2021
Code used in video - [Next + Strapi - Internationalization](https://www.youtube.com/watch?v=iqi3ZSp1cpE)
View [id].jsx
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 / list.phtml
Last active Mar 17, 2021
magento: Check if product is new in product listing
View list.phtml
<?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";
}
?>
@ivandoric
ivandoric / gist:e4e46294c4d35eac0ec8
Created Jun 5, 2014
wordpress: create custom reset password page
View gist:e4e46294c4d35eac0ec8
<?php //Add all of this tu custom page template ?>
<?php
global $wpdb;
$error = '';
$success = '';
// check if we're in reset form
if( isset( $_POST['action'] ) && 'reset' == $_POST['action'] )
{