Skip to content

Instantly share code, notes, and snippets.

View insaurabh's full-sized avatar
🎯
Focusing

Saurabh Ranjan insaurabh

🎯
Focusing
View GitHub Profile
Under every function there is an example of the output value:
Output : http://example.com/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>
Output : http://example.com/js/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); ?>
Output : http://example.com/index.php/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>
@insaurabh
insaurabh / function.php
Last active May 8, 2018 06:09
Custom additional values using pmpro-register-helper
function my_pmprorh_init()
{
$last_university = get_option('last_university');
$last_university = explode(',', $last_university);
$highest_level_of_education = get_option('highest_level_of_education');
$highest_level_of_education = explode(',', $highest_level_of_education);
// print_r($last_university);
if (!function_exists('pmprorh_add_registration_field'))
@insaurabh
insaurabh / extend.php
Last active June 16, 2018 14:57
Magento 2 file extend
#File name : /your-custom-module/view/frontend/layout/catalog_product_view.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="[Namespace]\[Modulename]\Block\Product\View\SomeName"
after="-"
name="customname.somename"
template="product/view/custom_template_name.phtml" />
</referenceContainer>
@insaurabh
insaurabh / meta-box-filed-repeater.php
Created August 21, 2018 09:32
add meta box with input field repeater wordpress
<?php
/**
* Create custom meta box
*/
// code is taken from stackoverflow and did some changes as per requirements.
add_action( 'add_meta_boxes', 'dynamic_add_box' );
/* Do something with the data entered */
@insaurabh
insaurabh / cli-commands-magento-1.9.txt
Created August 24, 2018 06:45
Magento 1.9 CLI commands | re-indexing | catalog_category_flat | catalog_category_product | catalogsearch_fulltext | reindexall
These is Individual commands for re-indexing:-
php shell/indexer.php --reindex catalog_category_flat
php shell/indexer.php --reindex catalog_category_product
php shell/indexer.php --reindex catalogsearch_fulltext
OR run all re-indexing:-
@insaurabh
insaurabh / title-and-meta-ajax-search-wordpress.php
Last active September 25, 2018 12:24
ajax search for title and custom meta in wordpress
/**
* Shortcode for property serach form
* @author Saurabh Ranjan
* <button type="button">Review Property</button>
*/
TODO:
1) chagne `post_type` as per your need
2) change `custom_meta` as per your need
3) Update $HTML as per need
@insaurabh
insaurabh / xml-to-array.php
Last active September 26, 2018 18:51
Practising xml to array and php loops
<?php
$url = 'fileName.xml';
$xml = simplexml_load_file($url); // load
$jsonEncode = json_encode($xml); // encode
$arrayData = json_decode($jsonEncode,TRUE); // decode , that's it now every thing is in array no need to query as object or parse to string
dump($arrayData['residential'][0]['agentID']);
dump($arrayData['residential'][0]['uniqueID']);
dump($arrayData['residential'][0]['tenancy']);
@insaurabh
insaurabh / InsertDate.gs
Created October 1, 2018 06:05 — forked from thomxc/InsertDate.gs
Google Docs Script Macro: Insert Date
/**
* The onOpen function runs automatically when the Google Docs document is
* opened. Use it to add custom menus to Google Docs that allow the user to run
* custom scripts. For more information, please consult the following two
* resources.
*
* Extending Google Docs developer guide:
* https://developers.google.com/apps-script/guides/docs
*
* Document service reference documentation:
<?php
// get the attribute
add_action( 'woocommerce_shop_loop_item_title', 'show_attribute_custom_action', 15 );
function show_attribute_custom_action() {
global $product;
$sizeAttribute = array_shift( wc_get_product_terms( $product->id, 'pa_size', array( 'fields' => 'names' ) ) );
@insaurabh
insaurabh / debug.php
Last active January 17, 2019 05:25
How to write log in wordpress from child theme.
// add in child theme function.php
// For more info : https://codex.wordpress.org/Debugging_in_WordPress
// Step 1 : define( 'WP_DEBUG', true );
// Step 2 : define( 'WP_DEBUG_LOG', true );
// Step 3 : Paste the below code in child theme function.php
// Step 4 : Call the function as : hb_write_log('lets debug');
// Step 5 : See the logs @ /website-entry-point/wp-content/debug.log ( if there is no file create a one with same name.)
if (!function_exists('hb_write_log')) {
function hb_write_log($log) {