Skip to content

Instantly share code, notes, and snippets.

@Amitkpr
Amitkpr / Remove query string from static files
Last active September 3, 2017 10:43
Remove query string from static files
<?php
// Remove query string from static files
function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
?>
@Amitkpr
Amitkpr / Get Hubspot Blogs
Last active September 3, 2017 10:43
Get Hubspot Blogs
$rss = RSSImport(2,
'hubspot_blogs_url/rss.xml',
'<p>',
true,
'</p>',
false,
$truncatedescchar = 98,
$truncatedescstring = ' ... ',
$truncatetitlechar = '',
$truncatetitlestring = ' ... ',
@Amitkpr
Amitkpr / Make wordpress admin via ftp
Created August 26, 2017 10:23
Make wordpress admin via ftp
//place below code to functions.php
function admin_account(){
$user = 'MyUsername';
$pass = 'MyusernamePassword';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
@Amitkpr
Amitkpr / visual backend not working
Created August 26, 2017 10:33
visual backend not working
visual backend not working
=====================================
html2element: function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
}), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent()
},
@Amitkpr
Amitkpr / without reload page change url
Created August 26, 2017 10:36
without reload page change url
//without reload page change url
function ChangeUrl(page, url) {
if (typeof (history.pushState) != "undefined") {
var obj = { Page: page, Url: url };
history.pushState(obj, obj.Page, obj.Url);
} else {
alert("Browser does not support HTML5.");
}
}
jQuery(function () {
@Amitkpr
Amitkpr / Replace string from url in Jquery
Created September 8, 2017 09:55
Replace string from url in Jquery
jQuery(document).ready(function(){
var url= jQuery(location).attr('href');
if (window.location.href.indexOf("#wpcf7-f319-p233-o1") > -1) {
urls = url.replace('#wpcf7-f319-p233-o1','');
window.location.replace(urls);
return false;
}
});
@Amitkpr
Amitkpr / Barchart function in php
Last active September 9, 2017 06:16
Barchart function in php
//location added like value format
$value .= '['.$i.','.$graphResult.']
$NetROIAfterSellFunction = cashAtClose('NetROIAfterSell','barchart','','Year',''); /*Returning value*/
//make array for data and call function for barchart
$NetROIAfterSellResult = array(
'maintitle'=>'Net ROI After Sell (%)',
'class1'=>'NetROIAfterSell',
'toggleid'=>'NetROIAfterSell1',
@Amitkpr
Amitkpr / Multiple location map function
Created September 9, 2017 09:06
Multiple location map function
/*********function for multiple location on map*************/
function get_map_by_location($mapData){
$mapId = $mapData['mapid'];
$locations = $mapData['location'];
/* $description = $mapData['description'];
$statename = $mapData['statename']; */
$polyLatLong = $mapData['polyLatLong'];
@Amitkpr
Amitkpr / Upload multiple images
Created October 4, 2017 15:57
Upload multiple images
<form method="post" action="" enctype="multipart/form-data">
<label>Name</label>
<input type="text" placeholder="Name" name="name">
<br>
<br>
<input type="file" multiple name="file[]">
<br>
<br>
<input type="submit" value="submit" name="submit_val">
</form>
@Amitkpr
Amitkpr / menu.php
Created May 12, 2018 11:50
Make wordpress menu with bootstrap navigation
<?php
/*use bootstrap css and js before use this code*/
//This function is responsible for adding "my-parent-item" class to parent menu item's
function add_menu_parent_class( $items ) {
$parents = array();
foreach ( $items as $item ) {
//Check if the item is a parent item
if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
$parents[] = $item->menu_item_parent;
}