Skip to content

Instantly share code, notes, and snippets.

@ercanertan
ercanertan / functions.php
Created January 6, 2023 18:20 — forked from yoren/functions.php
Parent Post From Another Post Type And A New URL Structure In WordPress
<?php
// Flush rewrite rules after switch theme
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
// A little help so we can get the stylesheet from parent theme
// Remove line 10-19 if this is not a child theme
function my_enqueue_styles() {
@ercanertan
ercanertan / instructions.md
Created February 26, 2022 18:44 — forked from ju5t/instructions.md
Livewire enabled TinyMCE blade component

Instructions

This is a very basic TinyMCE component. It uses 'entangle'. This allows you to link a Livewire and Alpine property to eachother. If one value changes, the other does too.

Installation

Add tinymce.blade.php to views/components/input. This can be another component folder too if you prefer, but keep in mind that you should also

@ercanertan
ercanertan / Fetch_example.md
Created June 23, 2021 20:02 — forked from jimgwhit/Fetch_example.md
Fetch simple example

Just test data and uptating one field using put:

    document.getElementById('submitBtn').addEventListener('click', submitPost);
    function submitPost(e) {
        e.preventDefault();
        const data = {petid: document.getElementById('petid').value,
            species: document.getElementById('species').value,
            _token: document.getElementsByName("_token")[0].value,
            _method: document.getElementsByName("_method")[0].value};
@ercanertan
ercanertan / JSON_Query.txt
Last active July 14, 2020 08:30
JSON Query with Laravel
// Sample Query
$page = Page::query()
->select('title',\DB::raw('advance_custom_fields->"$[*].field_type" AS field'))
->whereRaw('advance_custom_fields->"$[*].field_type" IS NOT NULL')
->whereRaw('JSON_SEARCH(advance_custom_fields, "one", "image") IS NOT NULL')
->get();
Table is pages
json coloumn is advance_custom_fields
@ercanertan
ercanertan / My JsFiddles
Created December 18, 2018 09:38
My JsFiddles
Scroll down animation on carousel - https://jsfiddle.net/qku98e4b/14/
@ercanertan
ercanertan / Laravel redirectTo() method
Last active December 19, 2018 17:57
Laravel redirectTo() method
// Dont use "return redirect.." because the method redirectTo should return an url path, not the Redirect response.
Example
protected function redirectTo() {
if (Auth::check() && Auth::user()->role == 'visitor') {
// Dont use redirect
// return redirect('/visitor'); // Wrong
return route('backend.visitor');
@ercanertan
ercanertan / Cookie Laravel.txt
Last active December 19, 2018 17:56
Cookie Laravel
@ercanertan
ercanertan / MacOSX Preparation.txt
Last active October 12, 2018 13:30
MacOSX Preparation
Install Brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Mysql
brew install mysql@5.7
brew services start mysql@5.7
http://jsfiddle.net/mt8wfrq2/
Blade
<div id="accordion" role="tablist">
<div class="card">
<div class="card-header" role="tab" id="headingOne">
<h5 class="mb-0">
<a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">