Skip to content

Instantly share code, notes, and snippets.

View gagimilicevic's full-sized avatar

Milicevic Dragan gagimilicevic

View GitHub Profile
@gagimilicevic
gagimilicevic / test.html
Created June 8, 2020 14:00
Textbox accept only numbers (digits) using jquery
Number : <input type="text" name="quantity" id="quantity" />&nbsp;<span id="errmsg"></span>
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show();
return false;
@gagimilicevic
gagimilicevic / form.html
Created June 8, 2020 11:06
Input text field - accept only numbers
onkeypress="return (event.charCode !=8 && event.charCode ==0 || (event.charCode >= 48 && event.charCode <= 57))"
@gagimilicevic
gagimilicevic / index.html
Created June 4, 2020 13:53 — forked from deepesh141291/index.html
Lazy Loading CSS Background Images with Intersection Observer
<div class="wrapper">
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
</div>
@gagimilicevic
gagimilicevic / functions.php
Created May 19, 2020 21:00
BuddyPress prevent duplicate Group Names
/**
* Create Shoebox - Check if Shoebox name already exists if does do not create duplicated shoebox.
*/
function dwply_check_group_name( $group_new ) {
if ( 'group-details' == bp_get_groups_current_create_step() ) {
$args = array(
'per_page' => null,
'populate_extras' => false,
'update_meta_cache' => false
);
@gagimilicevic
gagimilicevic / gist.php
Created April 26, 2020 11:30
Remove credentials on GIT repo on stage server
git config credential.helper 'cache --timeout=9000000'
@gagimilicevic
gagimilicevic / svg.php
Created April 16, 2020 22:11
Enable SVG support and enable svg upload
/**
* Enable SVG upload.
*/
function dwply_svgs_upload_mimes( $mimes = array() ) {
// allow SVG file upload
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
@gagimilicevic
gagimilicevic / content.php
Created April 12, 2020 20:26
Content builder helper functions
/**
* Register Flexible Content Group
*
* @since 1.0.0
*/
public function dwply_universalia_builder_register_flexible_content_group() {
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_5e7fbfdd8cbaa',
'title' => 'Universalia Content Builder',
@gagimilicevic
gagimilicevic / load.php
Created April 11, 2020 20:16 — forked from yratof/load.php
ACF Load layouts into flex field
<?php
add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' );
static function craft_content_layouts( $field ) {
// Remove the layouts
// that are named in this list
$remove_list = [
'paragraph',
'banner',
@gagimilicevic
gagimilicevic / custom-template-plugin.php
Created April 7, 2020 13:52 — forked from ashokmhrj/custom-template-plugin.php
Get Template Part From plugin directory
<?php
/**
* The below function will help to load template file from plugin directory of wordpress
* Extracted from : http://wordpress.stackexchange.com/questions/94343/get-template-part-from-plugin
*/
define('PLUGIN_DIR_PATH','Your-plugin-directory-path');
function ccm_get_template_part($slug, $name = null) {
do_action("ccm_get_template_part_{$slug}", $slug, $name);
@gagimilicevic
gagimilicevic / crawler_detect.php
Created April 1, 2020 18:08 — forked from geerlingguy/crawler_detect.php
Detect crawlers/bots/spiders in PHP (simple and fast)
<?php
/**
* Check if the given user agent string is one of a crawler, spider, or bot.
*
* @param string $user_agent
* A user agent string (e.g. Googlebot/2.1 (+http://www.google.com/bot.html))
*
* @return bool
* TRUE if the user agent is a bot, FALSE if not.