Skip to content

Instantly share code, notes, and snippets.

View newsapkota's full-sized avatar

Suresh Sapkota newsapkota

View GitHub Profile
@newsapkota
newsapkota / sublime-text-3-windows-shortcuts.md
Created July 2, 2018 14:00 — forked from mrliptontea/sublime-text-3-windows-shortcuts.md
Sublime Text 3 - Useful Shortcuts (Windows)

Sublime Text 3 - Useful Shortcuts (Windows)

General

Shortcut Description
Ctrl+Shift+P command prompt
Ctrl+Alt+P switch project
Ctrl+P go to file
Ctrl+G go to line
@newsapkota
newsapkota / export_csv.php
Created May 2, 2018 07:51 — forked from janschoepke/export_csv.php
MySQL CSV Export via PHP (PHP7 ready)
<?php
/* vars for export */
// database record to be exported
$db_record = 'XXX_TABLE_NAME_XXX';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
// filename for export
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
// database variables
@newsapkota
newsapkota / inputtitle_submit.js
Created March 30, 2018 16:19 — forked from jackreichert/inputtitle_submit.js
Example showing how to use AJAX in WordPress
(function ($) {
$(document).ready(function () {
$('#next').click(function () {
$.post(
PT_Ajax.ajaxurl,
{
// wp ajax action
action: 'ajax-inputtitleSubmit',
// vars
/* Bootstrap 4 - https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css */
.active
.alert
.alert-danger
.alert-dark
.alert-dismissible
.alert-heading
.alert-info
.alert-light
@newsapkota
newsapkota / auto-add.php
Created February 7, 2018 13:05 — forked from danielpataki/auto-add.php
OOP plugin
/*
Plugin Name: Auto Add Read Posts
Description: A plugin that adds read posts to the user's read list - requires the Unread Posts plugin
Version: 1.0.0
Author: Daniel Pataki
Author URI: http://danielpataki.com/
License: GPLv2 or later
*/
add_action( 'wp', 'auto_add_post_to_read_list' );
@newsapkota
newsapkota / abstraction-1.php
Created February 7, 2018 13:00 — forked from danielpataki/abstraction-1.php
OOP in Plugins
<div class='post' id='post-23'>
<h2><?php the_title() ?></h2>
<div class='excerpt'>
<?php
$content = get_the_content();
if( strlen($content) < 250 ) {
echo $content;
}
else {
$content = substr( $content, 0, 250 );
@newsapkota
newsapkota / cached-posts.php
Created February 4, 2018 02:39 — forked from danielpataki/cached-posts.php
WordPress REST API
public function get_remote_posts() {
$posts = get_transient( 'remote_posts' );
if( empty( $posts ) ) {
$response = wp_remote_get( 'http://mysite.com/wp-json/wp/v2/posts/' );
if( is_wp_error( $response ) ) {
return array();
}
$posts = json_decode( wp_remote_retrieve_body( $response ) );
@newsapkota
newsapkota / laravellocal.md
Created December 6, 2017 00:40 — forked from hootlex/laravellocal.md
Run laravel project locally

##Windows users:

cmder will be refered as console

##Mac Os, Ubuntu and windows users continue here:

  • Create a database locally named homestead utf8_general_ci
@newsapkota
newsapkota / media-query.css
Created September 27, 2017 01:49 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS