Skip to content

Instantly share code, notes, and snippets.

Avatar

sarankumar zarankumar

View GitHub Profile
View vtiger webform field is not saving - Quick Fix
/*
While installing new vtiger 6.5 or 7.0 you will face a troubele while creating webform. This is atually because of table error.
use following quick fix.
*/
CREATE TABLE vtiger_webforms_field (
id int(19) NOT NULL AUTO_INCREMENT,
webformid int(19) NOT NULL,
View create product gallery using POST method and wp-ajax
<?php
// Need to require these files
if ( !function_exists('media_handle_upload') ) {
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
// All data
View create product gallery using POST method and wp-ajax
<?php
// Need to require these files
if ( !function_exists('media_handle_upload') ) {
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
// All data
@zarankumar
zarankumar / file-upload-handler.php
Created Jul 10, 2017 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
View file-upload-handler.php
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@zarankumar
zarankumar / create-image-id.php
Created Jul 9, 2017 — forked from joshuadavidnelson/create-image-id.php
Programmatically create the image attachment and return the new media upload id.
View create-image-id.php
<?php
/**
* Create the image attachment and return the new media upload id.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*
* @since 03.29.2017 updated to a class, utilizing code from Takuro Hishikawa's gist linked below.
*
* @see https://gist.github.com/hissy/7352933
*
@zarankumar
zarankumar / add-woocommerce-product.php
Last active Jul 9, 2017 — forked from Yame-/add-woocommerce-product.php
Adding a WooCommerce product programmatically.
View add-woocommerce-product.php
<?php
$args = array(
'post_author' => 1,
'post_content' => '',
'post_status' => "draft", // (Draft | Pending | Publish)
'post_title' => '',
'post_parent' => '',
'post_type' => "product"
);
@zarankumar
zarankumar / Add image to product gallery programmatically - woocommerce
Last active Aug 1, 2022
Add image to product gallery programmatically - woocommerce .Woocommerce manage field ‘_product_image_gallery’ with id of images separatly for comma.
View Add image to product gallery programmatically - woocommerce
@zarankumar
zarankumar / plugin-settings.php
Created Apr 23, 2017 — forked from annalinneajohansson/plugin-settings.php
A base for a WordPress plugin settings page, using the Settings API #add_options_page #add_action #admin_init #register_setting #add_settings_section
View plugin-settings.php
<?php
# http://kovshenin.com/2012/the-wordpress-settings-api/
# http://codex.wordpress.org/Settings_API
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' );
}
add_action( 'admin_init', 'my_admin_init' );
View gist:ca52a6937d49cba4861702c0e3389fd4
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@zarankumar
zarankumar / gist:5391f7633fa739510616851b00f3820f
Created Apr 19, 2017
How to convert existing non-empty directory into a Git working directory and push files to a remote repository
View gist:5391f7633fa739510616851b00f3820f
cd <localdir>
git init
git add .
git commit -m 'message'
git remote add origin <url>
git push -u origin master