Advertisement
firoze

Data input by SMOF framework

Dec 18th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.55 KB | None | 0 0
  1. // Data input by using SMOF framework
  2.  
  3.  
  4. <!--single data usages-->
  5.  
  6. <img src="<?php global $data; echo $data['your_option_id']; ?>" alt="" />
  7.  
  8.  OR
  9. <?php echo do_shortcode(stripslashes($data['your_option_id']));?>
  10.                                                                                  <img src="<?php echo do_shortcode(stripslashes($data['your_option_id']));?>" alt="" />
  11.                                                                                 <!--if we use OR then we have to show global $data; into head where there
  12.                                                                                 is called (<?php wp_head();?>) usages will be like (<?php global $data; wp_head();?>)--> or you show  <?php global $data; ?> this anywhere any page
  13.  
  14.  
  15. <!--conditional data-->
  16.  
  17. <?php global $data; ?>
  18. <?php if($data['your_option_id']): ?>
  19.    <?php echo $data['your_option_id']; ?>   <!--here our data will show-- like <h2> <?php echo $data['your_option_id']; ?></h2>>
  20. <?php endif; ?>
  21.  
  22.  
  23. <!--conditional data with default data-->
  24.  
  25. <?php global $data; ?>
  26. <?php if($data['your_option_id']): ?>
  27.    <img src="<?php echo $data['your_option_id']; ?>" alt="" /><!--this will show only user selected options-->
  28. <?php else: ?>
  29.  <img src="<?php echo get_template_directory_uri();?>/images/header.png" alt=""/><!--My Default Data-->
  30. <?php endif; ?>
  31.  
  32.  
  33.  
  34. <!-- the above mention id(your_option_id) this also will be show in (SMOF)-->
  35.  
  36.  
  37.  
  38. Now you need to Put id into your themes html code with conditional data. At first I will show you three types of conditions.
  39. //  Single data:
  40. <?php global $data; echo $data ['your_option_id']; ?>
  41.  
  42. //  Conditional Data:
  43. <?php if ($data ['your_option_id']): ?>
  44.      <?php echo $data ['your_option_id']; ?>
  45.        <?php endif; ?>
  46.        
  47. //  Condition with Default Data:
  48.  
  49. <?php if ($data ['your_option_id']): ?>
  50.         <?php echo $data ['your_option_id']; ?>
  51.             <?php else: ?>
  52.              Your Default Data
  53.             <?php endif; ?>
  54.  
  55.  
  56.  
  57.  
  58.  
  59. /*background image changing by SMOF single shortcode*/
  60. function using_bg_shortcode($atts , $content=null){
  61.             extract(shortcode_atts(array(
  62.             ),$atts));
  63.                
  64.             global $data;
  65.             if($data['click_share_bg']):
  66.             return '<style type="text/css">
  67.     .click_share{background-image:url('.$data['click_share_bg'].'); background-repeat:no-repeat scroll center center;background-size:100% 100%;}
  68.     </style>';
  69.    
  70.     else:
  71.     return '<style type="text/css">.click_share{background-image:url('.get_stylesheet_directory_uri().'/images/clickbg.jpg); background-repeat:no-repeat scroll center center;background-size:100% 100%;}</style>';
  72.     endif;
  73. }
  74. add_shortcode('bg', 'using_bg_shortcode');
  75.  
  76. // shortcode will be like this
  77. <?php echo do_shortcode('[bg]');?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement