Skip to content

Instantly share code, notes, and snippets.

View sybozz's full-sized avatar
💭
Online

Sharif Ahmed sybozz

💭
Online
View GitHub Profile
@sybozz
sybozz / wp-ai-post-generator.php
Created May 29, 2024 12:41
WordPress plugin to generate post excerpt with OpenAI integraiton.
<?php
/*
Plugin Name: AI Post Generator
Description: Generate WordPress post content and excerpt using AI.
Version: 1.0
Author: sybozz
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
@sybozz
sybozz / create-wc-product-from-attachment.sql
Last active May 9, 2024 08:56
This SQL query will create WooCommerce product in WordPress by the attachment ID and the category id.
SET @attachment_id=2600;
SET @category_id=36;
SET @guid="http://yoursite.url/?post_type=product&p=";
insert into wp_posts (
post_title,
post_status,
post_name,
guid,
post_type,
@sybozz
sybozz / readme.md
Created November 26, 2021 04:49
DataGrip MySQL database setup with unix socket connection for Local WP app on Mac

First read the JetBrains doc for linux here at https://www.jetbrains.com/help/datagrip/how-to-connect-to-mysql-with-unix-sockets.html#step-5-create-a-connection-to-the-mysql-server

  1. download the driver files from https://github.com/kohlschutter/junixsocket/releases/tag/junixsocket-parent-2.3.4
  2. load the files into Drivers
  3. find the Local WP App's mysql.sock file from the app window: Local Sites > SITE > Database > Socket
  4. Put the file path of mysql.sock in DataGrip > Data Source > Drivers > MySql Socket > Advanced > junixsocket.file
@sybozz
sybozz / ajax-laravel-post-request.js
Last active March 5, 2020 17:38
ajax post request from Lavel blade with csrf token and name route with id inside js script
<script>
$(function () {
$('input[name="status"]').change(function () {
let subscriptionId = $(this).val();
let statusUpdateRequest = '{{ route('subscriptions.status.update', ':id') }}';
statusUpdateRequest = statusUpdateRequest.replace(':id', subscriptionId);
$.ajax({
@sybozz
sybozz / portlet.blade.php
Created December 3, 2019 08:04
Html element tag with attributes using php http_build_query and urldecode
@component('common.portlet', [
'title' => 'FAQs',
'actions' => [
'create' => ['route' => route('faqs.create'), 'icon' => 'icon-plus', 'id' => 'createFaqBtn',
'attributes' => ['data-target' => '#createFaqModal']
]
]
]
)
@endcomponent
@sybozz
sybozz / chartjs.ajaxify.js
Created November 22, 2019 08:08
chart ajaxify to load last 12 months data
$(function () {
/**
* Ajaxify Pie Chart of Monthly Invoices Stats
* Data of datasets changes on selecting different month
* @return Object of Chart instance
**/
let monthlyInvoiceStatPieChart = document.getElementById('monthlyInvoiceStatsChart').getContext('2d');
let misPieChart = null;
@sybozz
sybozz / help.blade.php
Last active November 15, 2019 11:21
Help block in modal for form fields usign jquery. Simple to use by using data-help attribute. Pass the
// page content
@section('content')
...
//in form fields
<label for="name" class="control-label"> Coupon Name : <span class="required">*</span></label>
<input type="text" class="form-control" id="name" name="name" value="" data-help="couponNameHelp" placeholder="Coupon Name">
....
@endsection
@sybozz
sybozz / 1-readme.md
Last active February 24, 2023 01:10
Laravel DataTables using component

N|Solid

Laravel datatables using components

Todos

  • Write MORE Tests
  • Add Night Mode

License

@sybozz
sybozz / 1-readme.md
Last active September 19, 2019 14:32
Status update by radio button via ajax and notify using bootstarp notify in laravel

Updating status via ajax with radio buttons

ajax

bootstrap notify

replacing url from route that has args

Todos

  • Write MORE Tests
@sybozz
sybozz / 1-readme.md
Last active February 28, 2020 05:37
Laravel form element components for blade view with bootsrap forms - V2

DRY Forms V 2.0 components

Laravel blade components and slots

Bootstrap 4