{"id":442,"date":"2020-05-14T05:54:39","date_gmt":"2020-05-14T05:54:39","guid":{"rendered":"http:\/\/plugins.vjinfotech.com\/wordpress-import-export\/?post_type=ht_kb&#038;p=442"},"modified":"2020-05-16T06:09:51","modified_gmt":"2020-05-16T06:09:51","slug":"add-shortcode","status":"publish","type":"ht_kb","link":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/documentation\/add-shortcode\/","title":{"rendered":"Add Shortcode"},"content":{"rendered":"\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Warning :<\/strong> if you don&#8217;t have php knowledge then please don&#8217;t use this feature.<\/p>\n\n\n\n<p>shortcode allow user to filter or modify import data. user can call any php function and pass any number of argument.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"required-permission-for-non-admin-users\" >Required permission for non admin users<\/h3>\n\n\n\n<p>by default adding shortcode is allowed for admin users only. admin can give permission to any user role.<\/p>\n\n\n\n<p>for add permission go to WP Imp Export =&gt; Settings<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"954\" height=\"612\" src=\"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings.png\" alt=\"\" class=\"wp-image-453\" srcset=\"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings.png 954w, https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings-300x192.png 300w, https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings-768x493.png 768w, https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings-50x32.png 50w, https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings-920x590.png 920w, https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings-600x385.png 600w, https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-content\/uploads\/2020\/05\/add-shortcode-permission-settings-320x205.png 320w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/figure>\n\n\n\n<div style=\"height:70px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-use-shortcode\" >How to use shortcode<\/h3>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>[wpie_function custom_function=&#8221;my_custom_function&#8221; param1=&#8221;value1&#8243;]<\/p><\/blockquote>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>wpie_function<\/strong>: shortcode name<\/p>\n\n\n\n<p><strong>custom_function <\/strong>: fixed variable for use custom function<\/p>\n\n\n\n<p><strong>my_custom_function<\/strong> : any php function name that you want to call<\/p>\n\n\n\n<p><strong>param1=&#8221;value1&#8243;<\/strong> any parameter you pass. you can pass unlimited parameters.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-1-multiply-values\" >Example 1 : multiply values<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;wpie_function custom_function=\"increase_my_price\" data1=\"{price&#91;1]}\" data2=\"20\" data3=\"50\"]<\/code><\/pre>\n\n\n\n<p>here {price[1]} is drag and drop field from list. it may change in all files. data1, data2, data3 are parameters and you can pass unlimited parameters<\/p>\n\n\n\n<p>add function in themes <strong>function.php<\/strong> file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function increase_my_price( $data = &#91;],$content=\"\" ) {\n           $data1= isset( $data&#91; \"data1\" ] ) ? $data&#91; \"data1\" ] : 1;\n           $data2 = isset( $data&#91; \"data2\" ] ) ? $data&#91; \"data2\" ] : 1;\n           $data3 = isset( $data&#91; \"data3\" ] ) ? $data&#91; \"data3\" ] : 1;\n           return $data1 * $data2 * $data3;\n}<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-2-add-prefix\" >Example 2 : add prefix<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;wpie_function custom_function=\"add_my_prefix\" data=\"{custom&#91;1]}\" prefix=\"test_\"]<\/code><\/pre>\n\n\n\n<p>here {custom[1]} is drag and drop field from list. it may change in all files. data, prefix are parameters and you can pass unlimited parameters<\/p>\n\n\n\n<p>add function in themes <strong>function.php<\/strong> file <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function add_my_prefix( $attr = &#91;],$content=\"\" ) {        \n        $data= isset( $attr&#91; \"data\" ] ) ? $attr&#91; \"data\" ] : \"\";\n        $prefix= isset( $attr&#91; \"prefix\" ] ) ? $attr&#91; \"prefix\" ] : \"\";\n        return $prefix.$data;\n}<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-3-replace-link-in-content\" >Example 3 : Replace link in content<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;wpie_function custom_function=\"replace_my_links\" data=\"{content&#91;1]}\" search=\"http:\/\/demo.example.com\" replace=\"http:\/\/www.vjinfotech.com\"]<\/code><\/pre>\n\n\n\n<p>here {content[1]} is drag and drop field from list. it may change in all files. data, search and replace are parameters and you can pass unlimited parameters<\/p>\n\n\n\n<p>add function in themes <strong>function.php<\/strong> file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function replace_my_links( $attr = &#91;], $content = \"\" ) {\n        $data = isset( $attr&#91; \"data\" ] ) ? $attr&#91; \"data\" ] : \"\";\n        if ( empty( $data ) ) {\n                return \"\";\n        }\n        $search = isset( $attr&#91; \"search\" ] ) ? $attr&#91; \"search\" ] : \"\";\n        $replace = isset( $attr&#91; \"replace\" ] ) ? $attr&#91; \"replace\" ] : \"\";\n        $new_content = str_replace( $search, $replace, $data );\n        return $new_content;\n}<\/code><\/pre>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht_kb_category":[15],"ht_kb_tag":[],"class_list":["post-442","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-advanced-options"],"_links":{"self":[{"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/ht_kb\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":36,"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/ht_kb\/442\/revisions"}],"predecessor-version":[{"id":492,"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/ht_kb\/442\/revisions\/492"}],"wp:attachment":[{"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/media?parent=442"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/ht_kb_category?post=442"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/plugins.vjinfotech.com\/wordpress-import-export\/wp-json\/wp\/v2\/ht_kb_tag?post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}