Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-----------------------------------------------------Short Code Basic and Google Map Short Code----------------------------------->
- <?php
- /*
- This file contain about Basic and Advance Short code.How to use short code and how it implement this code.
- */
- /*===============================Basic Short Code=========================================*/
- function add_basic_shortcode($a,$b=null){
- return(<div class="sumon">'.$b.'</div>);
- }
- add_shortcode('add_basic_shortcode','add_basic_shortcode');
- /*
- Above code Description
- 1.At first write a function and give any name that function.
- 2.Than I am taking two parameter($a and $b)
- 3.$b variable is empty because return $b value
- 4.$a this variable specify wordpress content.
- */
- /*If u want to add images using short code see the blew code */
- function add_basic_shortcode($a,$b=null){
- return(<img src="'.$b.'" alt="" />);
- }
- add_shortcode('add_basic_shortcode','add_basic_shortcode');
- /*=========================Advance Short Code in Wordprss=============================*/
- function advance_shortcode($atts,$content=null){
- extract(shortcode_atts(array(
- 'title'=>'this is title',(/*এই গুলো page and post এর attributes আপনি যত ইচ্ছা তত attribute ব্যবহার করতে পারতে পারেন */)
- 'link'=>'#or you give a link',
- 'text'=>'this is default text',
- 'images'=>'blank or give an images link or location',
- 'author_name'=>'here is author name'
- )$atts,));
- return'<h2>'.$title.'</h2><a href="'.$link.'"></a><p>'.$text.'</p><img src="'.$images.'" alt="" /><h5>'.$author_name.'</h5><div class="sumon">'.$content.'</div>';
- }
- add_shortcode('advance_shortcode','advance_shortcode');
- /*=======================================উপরের code এর বর্ণনা(Advance) ==============================*/
- /*
- ১. প্রথমে একটা function নিলাম। fucnton এর নাম যা ইচ্ছা তাই নেয়া যাবে।
- ২। তারপর add_shortcode করে সেই fucntion কে wordpress এর সাথে hookup(জুড়ে দেয়া হল ) করে দেয়া হল ।
- ৩। তারপর extract() function ব্যবহার করা হয়েছে। extract() function এর কাজঃ extract() funcstioটি arry এর element(title,link,text,images,images etc.)value টাকে নিচের variable এর মধ্য ($title,$link,$text,$images,$author_name etc.) নিয়ে দেয় এবং তা print করাতে সাহায্য করে। মোটকথা array মধ্যকার সকল value print করে।
- ৪.$atts এই variable টি মুলত wordpress এ content show করাতে handler হিসাবে কাজ করে।
- ৫.আমরা যেহেতু function ব্যবহার করেছি সুতরং আমাদেরকে value কে return করাতে হবে। আমরা যে value গুলো দেখাতে চাই তা আমাদের এই return এর মধ্য রাখতে হবে।
- ৬। উপরের সব বকবক page and post attributes দেয়ার জন্য
- ৭. content add করার জন্য $content যেখানে চাই সেখানে দিতে হবে।
- */
- /*google map using short code*/
- function googe_map($atts,$content=null){
- extract(shortcode_atts(array(
- 'width'=>'',
- 'height'=>'',
- 'link'=>'https://maps.google.com/'
- ),$atts));
- return'<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='.$content.'&aq=&ie=UTF8&hq=&hnear='.$content.'&output=embed"></iframe>';
- }
- add_shortcode( 'googe_map', 'googe_map' );
- /*short code for social media*/
- function twitter($atts,$content=null){
- extract(shortcode_atts(array(
- 'data_width'=>'',
- 'language'=>'',
- 'size'=>'',
- 'count'=>'',
- 'screen_name'=>'',
- 'link'=>''
- ),$atts));
- return'<a href="'.$content.'" class="twitter-follow-button" data-show-count="'.$count.'" data-width="'.$data_width.'" data-lang="'.$language.'" data-size="'.$size.'" data-align="left" data-show-screen-name="'.$screen_name.'">Raihan Webpro @twitter</a>
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
- }
- add_shortcode( 'twitter', 'twitter' );
- /*facebook like button*/
- function fb($atts,$content=null){
- extract(shortcode_atts(array(
- 'layout'=>'',
- 'like'=>'',/*or recommend*/
- 'width'=>'',
- 'count'=>'',
- 'screen_name'=>'',
- 'link'=>''
- ),$atts));
- return'<div class="fb-like" data-href="'.$content.'" data-layout="'.$layout.'" data-action="'.$like.'" data-show-faces="true" data-share="true" data-width="'.$width.'"></div>';
- }
- add_shortcode( 'fb', 'fb' );
- /*
- Above code description
- ১. প্রথমে google map থেকে আমি link নিয়ে আসলাম। আপনি যে জায়গার map দেখাতে চান সে জায়গা search করে তার link নিয়ে আসবেন।
- তারপর link টি short code এর return এর মাঝে দিয়ে দিবেন । তার পর iframe tag এর class নিয়ে অথবা shortcode এর attributes নিয়ে styleing করতে পারেন।
- ২. আপনি যদি চান client short code এর মাঝে সুধু location দিবে আর map চলে আসবে সেই জায়গার , সেক্ষেত্রে
- <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=JHENIDAH,+KHULNA+DIVISION,+BANGLADESH&AQ=0&OQ=JHENIDAH&SLL=37.0625,-95.677068&SSPN=42.174768,56.513672&ie=UTF8&hq=&hnear=Jhenaidah,+Khulna+Division,+Bangladesh&T=M&Z=9&LL=23.475416,89.1706&output=embed"></iframe>
- আপনার location এর নামের জায়গায় (JHENIDAH,+KHULNA+DIVISION,+BANGLADESH&AQ=0&OQ=JHENIDAH)sohort code এর $content দিতে হবে।
- latitude(t=m&z=9&LL=23.475416,89.1706&), longitude(SLL=37.0625,-95.677068&SSPN=42.174768,56.513672&)বাদ যাবে।
- এভাবে short code লিখে wordpress যে পেজ এ location দেখাতে চান সে পেজ এ যাবেন এবং [] এর মাঝে location এর নাম দিলে আপনার location map দেখাবে। []
- Dedicated to:Raihan Kabir.
- */
- ?>
Add Comment
Please, Sign In to add comment