i am creating a plugin which is for promotions..Like the user can add events(Diwali,Holi) etc. called promotions.For every promotion there are options to add the Logo,Header,Background Image with the From and To date..It is the time when the Promotion will be started,When the Dates will arrive it should implement these changes(Logo,banner etc.) to my site frontend.But found no hook in wordpress which can implement these changes automatically instead the use of shortcode or any editing in file.please help me out.this is the code of my frontend file
function run_me()
{
$class_of_logo=get_option('logo_css_class');
$class_of_background=get_option('background_css_class');
$class_of_banner=get_option('banner_css_class');
$class_of_header=get_option('header_css_class');
//echo "i am working";
$services_loop = new WP_Query(
array(
'post_type' => 'promotion',
'posts_per_page' => -1,
'post_status' => 'publish'
));
while ($services_loop->have_posts()) : $services_loop->the_post();
$id=get_the_ID();
$from_date=get_post_meta( $id, 'your_prefix_date1', true );
$final_from_date = date('M/j/Y',strtotime($from_date));
$to_date=get_post_meta( $id, 'your_prefix_date2', true );
$final_to_date = date('M/j/Y',strtotime($to_date));
$file1 = get_post_meta( $id, 'your_prefix_file1', true );
$logo_image=wp_get_attachment_url( $file1 );
$file2 = get_post_meta( $id, 'your_prefix_file2', true );
$header_image=wp_get_attachment_url( $file2 );
$file3 = get_post_meta( $id, 'your_prefix_file3', true );
$background_image=wp_get_attachment_url( $file3 );
$file4 = get_post_meta( $id, 'your_prefix_file4', true );
$banner_image=wp_get_attachment_url( $file4 );
$active = get_post_meta( $id, 'your_prefix_radio', true );
$today_date=date('M/j/Y');
if($today_date==$final_from_date && $final_to_date > $today_date && $active=="value1" )
{
//get the ID of the Active Promotion
$iid=get_the_ID();
global $iid;
//Function To add the shortcode for Area One Text
function get_value_of_areaone()
{
global $iid;
echo $area1 = get_post_meta($iid, 'your_prefix_area1', true );
}
add_shortcode('area1','get_value_of_areaone');
//Function To add the shortcode for Area Two Text
function get_value_of_areatwo()
{
global $iid;
echo $area2 = get_post_meta( $iid, 'your_prefix_area2', true );
}
add_shortcode('area2','get_value_of_areatwo');
//Function To add the shortcode for Promotion Page Link
function get_value_of_page()
{
global $iid;
$page_id = get_post_meta( $iid, 'your_prefix_page', true );
$page_link=get_page_link( $page_id );
?>
<a href="<?php echo $page_link; ?>">click me</a>
<?php
}
add_shortcode('page_link','get_value_of_page');
?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function()
{
//alert("hey0");
//alert("<?php echo $class_of_logo; ?>");
//alert("<?php echo $iid=get_the_ID(); ?>");
if(!('<?php echo $logo_image; ?>' ==""))
{
jQuery("body").find("<?php echo $class_of_logo; ?>").attr( "src", "<?php echo $logo_image;?> " );
}
if(!('<?php echo $header_image; ?>' ==""))
{
jQuery("body").find("<?php echo $class_of_header; ?>").css({"background":"url(<?php echo $header_image;?>)no-repeat " ,"background-size":"100%"});
}
if(!('<?php echo $background_image; ?>' ==""))
{
jQuery("body").find("<?php echo $class_of_background; ?>").css( "background-image", "url(<?php echo $background_image;?>) no-repeat " );
}
if(!('<?php echo $banner_image; ?>' ==""))
{
jQuery("#main-content").prepend("<div class=slider_banner><img src=<?php echo $banner_image; ?>></div>");
}
});
</script>
<?php
} add_action('wp_head','run_me');?>