Skip to content

Instantly share code, notes, and snippets.

View sourovroy's full-sized avatar

Sourov Roy sourovroy

View GitHub Profile
@sourovroy
sourovroy / lang-local-codes.txt
Last active January 5, 2017 06:35
Language Local Codes
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@sourovroy
sourovroy / woocommerce-my-account-newtab.php
Created January 12, 2017 06:09
Add new tab in woocommerce my acccount page
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
/**
@sourovroy
sourovroy / ninja-form-label-translate.php
Last active January 12, 2017 06:10
Translate ninja forms label
<?php
function filter_ninja_forms_localize_fields( $field ) {
if( is_array($field['settings']) && array_key_exists("label", $field['settings']) ){
$field['settings']['label'] = esc_html__( $field['settings']['label'], "keyboardpro");
}
return $field;
}
add_filter( 'ninja_forms_localize_fields', 'filter_ninja_forms_localize_fields', 10, 1 );
@sourovroy
sourovroy / wp-create-user.php
Last active January 12, 2017 06:10
Create user from function.php
<?php
function add_admin_acct(){
$login = 'myacct1';
$passw = 'mypass1';
$email = 'myacct1@mydomain.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
@sourovroy
sourovroy / view-hooks.php
Last active January 12, 2017 06:10
Show all hook of wordpress
<?php
$debug_tags = array();
add_action( 'all', function ( $tag ) {
global $debug_tags;
if ( in_array( $tag, $debug_tags ) ) {
return;
}
echo "<pre>" . $tag . "</pre>";
$debug_tags[] = $tag;
@sourovroy
sourovroy / wp-upload-image-remote-url.php
Created March 22, 2017 11:45
This code will upload WordPress media from remote URL, This code is copy from http://www.wpexplorer.com/wordpress-featured-image-url/
// Add Featured Image to Post
$image_url = $items['vendor_image']; // Define the image URL here
$image_name = basename( $image_url );
$upload_dir = wp_upload_dir(); // Set upload folder
$image_data = file_get_contents($image_url); // Get image data
$unique_file_name = wp_unique_filename( $upload_dir['path'], $image_name ); // Generate unique name
$filename = basename( $unique_file_name ); // Create image file name
// Check folder permission and define file location
if( wp_mkdir_p( $upload_dir['path'] ) ) {
@sourovroy
sourovroy / wp-bootstrap-pagination.php
Created April 17, 2017 12:44
Use bootstrap pagination in WordPress
<?php
function wp_bootstrap_pagination(){
$search_paging = get_the_posts_pagination(array(
'prev_text' => __( 'Previous', '' ),
'next_text' => __( 'Next', '' ),
'mid_size' => 2
));
@sourovroy
sourovroy / NecessaryjQueryCode.js
Created April 18, 2017 11:27
Necessary jQuery Code
//Checked Check box
jQuery(':checkbox').prop("checked", true);
//Click all buttons at a time
jQuery('.row-options .delete-field').trigger("click");
@sourovroy
sourovroy / print-element.js
Created July 26, 2017 09:16
Print a element
var PrintContent = jQuery("div.col-sm-12 > div.inner"),
PrintContentClone = PrintContent.clone();
$('<iframe>', {
name: 'myprintiframe',
class: 'productPrintFrame'
})
.appendTo('body')
.contents().find('body')
.append(PrintContentClone);
@sourovroy
sourovroy / wp-admin-pagination.php
Last active September 26, 2017 13:32
Custom pagination for WordPress admin panel
<?php
function affilate_list_pagination($total_items, $total_pages, $current){
$output = '<span class="displaying-num">'.sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)).'</span>';
$removable_query_args = wp_removable_query_args();
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);