Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Data input by using SMOF framework
- <!--single data usages-->
- <img src="<?php global $data; echo $data['your_option_id']; ?>" alt="" />
- OR
- <?php echo do_shortcode(stripslashes($data['your_option_id']));?>
- <img src="<?php echo do_shortcode(stripslashes($data['your_option_id']));?>" alt="" />
- <!--if we use OR then we have to show global $data; into head where there
- is called (<?php wp_head();?>) usages will be like (<?php global $data; wp_head();?>)--> or you show <?php global $data; ?> this anywhere any page
- <!--conditional data-->
- <?php global $data; ?>
- <?php if($data['your_option_id']): ?>
- <?php echo $data['your_option_id']; ?> <!--here our data will show-- like <h2> <?php echo $data['your_option_id']; ?></h2>>
- <?php endif; ?>
- <!--conditional data with default data-->
- <?php global $data; ?>
- <?php if($data['your_option_id']): ?>
- <img src="<?php echo $data['your_option_id']; ?>" alt="" /><!--this will show only user selected options-->
- <?php else: ?>
- <img src="<?php echo get_template_directory_uri();?>/images/header.png" alt=""/><!--My Default Data-->
- <?php endif; ?>
- <!-- the above mention id(your_option_id) this also will be show in (SMOF)-->
- Now you need to Put id into your themes html code with conditional data. At first I will show you three types of conditions.
- // Single data:
- <?php global $data; echo $data ['your_option_id']; ?>
- // Conditional Data:
- <?php if ($data ['your_option_id']): ?>
- <?php echo $data ['your_option_id']; ?>
- <?php endif; ?>
- // Condition with Default Data:
- <?php if ($data ['your_option_id']): ?>
- <?php echo $data ['your_option_id']; ?>
- <?php else: ?>
- Your Default Data
- <?php endif; ?>
- /*background image changing by SMOF single shortcode*/
- function using_bg_shortcode($atts , $content=null){
- extract(shortcode_atts(array(
- ),$atts));
- global $data;
- if($data['click_share_bg']):
- return '<style type="text/css">
- .click_share{background-image:url('.$data['click_share_bg'].'); background-repeat:no-repeat scroll center center;background-size:100% 100%;}
- </style>';
- else:
- 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>';
- endif;
- }
- add_shortcode('bg', 'using_bg_shortcode');
- // shortcode will be like this
- <?php echo do_shortcode('[bg]');?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement