Skip to content

Instantly share code, notes, and snippets.

View nikola0203's full-sized avatar

Nikola Milosevic nikola0203

  • SEO 1 Click
  • Belgrade, Serbia
View GitHub Profile
@brunoleles
brunoleles / readme.md
Last active January 22, 2021 15:10
Gulp Watch Fails with "Error: watch ... ENOSPC"

gulp watch fails with error: Error: watch ... ENOSPC

Stacktrace:

[13:58:28] Starting 'watch'...
[13:58:28] 'watch' errored after 22 ms
[13:58:28] Error: watch /.../resources/assets/images/ ENOSPC
    at exports._errnoException (util.js:1023:11)
    at FSWatcher.start (fs.js:1306:19)
 at Object.fs.watch (fs.js:1331:11)
@gagimilicevic
gagimilicevic / translate_woocommerce.php
Created July 20, 2017 13:53 — forked from dannyconnolly/translate_woocommerce.php
Change SKU text label in woocommerce to Product Code
function translate_woocommerce($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'SKU':
$translation = 'Product Code';
break;
case 'SKU:':
$translation = 'Product Code:';
break;
@gagimilicevic
gagimilicevic / get-fisrt-paragraph.php
Created August 15, 2017 10:12 — forked from banago/get-fisrt-paragraph.php
Get first paragraph from a WordPress post.
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );
@gagimilicevic
gagimilicevic / gist:9c4dac6ac6ef7cdbef49c60d0c0bb1f7
Created August 18, 2017 09:50 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
$product_id = 64;
$found = false;
//check if product already in cart
@gagimilicevic
gagimilicevic / gist:6082f633bdec20f5d3ef80ca64c6a50f
Created August 18, 2017 09:51 — forked from woogist/gist:5934881
Automatically add product to cart on visit depending on cart total value
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit depending on cart total value
add_action( 'init', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 2831;
$found = false;
@gagimilicevic
gagimilicevic / paging.php
Created August 23, 2017 08:39 — forked from sloped/paging.php
Bootstrap Paging and Wordpress
<?php
//Use this function to create pagingation links that are styleable with Twitter Bootstrap
function paging() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
@gagimilicevic
gagimilicevic / bootstrap-pagination.php
Created August 23, 2017 08:39 — forked from ediamin/bootstrap-pagination.php
Bootstrap Pagination for WordPress
/*
* custom pagination with bootstrap .pagination class
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
*/
function bootstrap_pagination( $echo = true ) {
global $wp_query;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@gagimilicevic
gagimilicevic / wp-get_id_by_slug
Created September 1, 2017 12:53 — forked from davidpaulsson/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@gagimilicevic
gagimilicevic / latest-and-first.php
Created September 4, 2017 09:20 — forked from gbyat/latest-and-first.php
get latest and first post in WordPress
/******************************************
* get latest post
* use in loop if ( is_latest() ) { stuff; }
******************************************/
function is_latest() {
global $post;
$loop = get_posts( 'numberposts=1' );
$latest = $loop[0]->ID;
return ( $post->ID == $latest ) ? true : false;
}