function yasr_auto_insert_shortcode_callback($content) { $auto_insert_shortcode = NULL; //To avoid undefined variable notice outside the loop (if (is_singular) ) $overall_rating_code = '[yasr_overall_rating size="' . YASR_AUTO_INSERT_SIZE . '"]'; $visitor_votes_code = '[yasr_visitor_votes size="' . YASR_AUTO_INSERT_SIZE . '"]'; if (YASR_AUTO_INSERT_WHAT === 'overall_rating') { switch (YASR_AUTO_INSERT_WHERE) { case 'top': $content_and_stars = $overall_rating_code . $content; break; case 'bottom': $content_and_stars = $content . $overall_rating_code; break; } //End Switch } elseif (YASR_AUTO_INSERT_WHAT === 'visitor_rating') { switch (YASR_AUTO_INSERT_WHERE) { case 'top': $content_and_stars = $visitor_votes_code . $content; break; case 'bottom': $content_and_stars = $content . $visitor_votes_code; break; } //End Switch } elseif (YASR_AUTO_INSERT_WHAT === 'both') { switch (YASR_AUTO_INSERT_WHERE) { case 'top': $content_and_stars = $overall_rating_code . $visitor_votes_code . $content; break; case 'bottom': $content_and_stars = $content . $overall_rating_code . $visitor_votes_code; break; } //End Switch } //IF auto insert must work only in custom post type if (YASR_AUTO_INSERT_CUSTOM_POST_ONLY === 'yes') { $custom_post_types = yasr_get_custom_post_type(); //If is a post type return content and stars if (is_singular($custom_post_types)) { return $content_and_stars; } else { return $content; } } //If page are not excluded if (YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no') { return $content_and_stars; } elseif (YASR_AUTO_INSERT_EXCLUDE_PAGES === 'yes') { if (!is_page()) { return $content_and_stars; } else { return $content; } } }
function yasr_auto_insert_callback($option) { ?> <strong><?php _e('Use Auto Insert?', 'yasr'); ?> </strong> <br /> <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['auto_insert_enabled'] == 1) { echo " checked='checked' "; } ?> /> <?php _e('Yes', 'yasr'); ?> <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='0' id='yasr_auto_insert_radio_off' <?php if ($option['auto_insert_enabled'] == 0) { echo " checked='checked' />"; } else { echo "/>"; } _e('No', 'yasr'); ?> <p> </p> <strong><?php _e('What?', 'yasr'); ?> </strong> <br /> <input type="radio" name="yasr_general_options[auto_insert_what]" value="overall_rating" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_what'] === 'overall_rating') { echo " checked=\"checked\" "; } ?> > <?php _e('Overall Rating / Author Rating', 'yasr'); ?> <br /> <input type="radio" name="yasr_general_options[auto_insert_what]" value="visitor_rating" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_what'] === 'visitor_rating') { echo " checked=\"checked\" "; } ?> > <?php _e('Visitor Votes', 'yasr'); ?> <br /> <input type="radio" name="yasr_general_options[auto_insert_what]" value="both" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_what'] === 'both') { echo " checked=\"checked\" "; } ?> > <?php _e('Both', 'yasr'); ?> <p> </p> <strong><?php _e('Where?', 'yasr'); ?> </strong> <br /> <input type="radio" name="yasr_general_options[auto_insert_where]" value="top" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_where'] === 'top') { echo " checked=\"checked\" "; } ?> > <?php _e('Before the post', 'yasr'); ?> <br /> <input type="radio" name="yasr_general_options[auto_insert_where]" value="bottom" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_where'] === 'bottom') { echo " checked=\"checked\" "; } ?> > <?php _e('After the post', 'yasr'); ?> <br /> <p> </p> <strong><?php _e('Size', 'yasr'); ?> </strong> <br /> <div class="yasr-option-size"> <input type="radio" name="yasr_general_options[auto_insert_size]" value="small" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_size'] === 'small') { echo " checked=\"checked\" "; } ?> > <img src="<?php echo YASR_IMG_DIR . "yasr-stars-small.png"; ?> " class="yasr-img-option-size"><span class="yasr-text-options-size"><?php _e('Small', 'yasr'); ?> </span> </div> <div class="yasr-option-size"> <input type="radio" name="yasr_general_options[auto_insert_size]" value="medium" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_size'] === 'medium') { echo " checked=\"checked\" "; } ?> > <img src="<?php echo YASR_IMG_DIR . "yasr-stars-medium.png"; ?> " class="yasr-img-option-size"><span class="yasr-text-options-size"><?php _e('Medium', 'yasr'); ?> </span> </div> <div class="yasr-option-size"> <input type="radio" name="yasr_general_options[auto_insert_size]" value="large" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_size'] === 'large') { echo " checked=\"checked\" "; } ?> > <img src="<?php echo YASR_IMG_DIR . "yasr-stars-large.png"; ?> " class="yasr-img-option-size"><span class="yasr-text-options-size"><?php _e('Large', 'yasr'); ?> </span> </div> <p> </p> <strong><?php _e('Exclude Pages?', 'yasr'); ?> </strong> <br /> <input type="radio" name="yasr_general_options[auto_insert_exclude_pages]" value="yes" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_exclude_pages'] === 'yes') { echo " checked=\"checked\" "; } ?> > <?php _e('Yes', 'yasr'); ?> <input type="radio" name="yasr_general_options[auto_insert_exclude_pages]" value="no" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_exclude_pages'] === 'no') { echo " checked=\"checked\" "; } ?> > <?php _e('No', 'yasr'); ?> <br /> <p> </p> <?php $custom_post_types = yasr_get_custom_post_type('bool'); if ($custom_post_types) { ?> <strong><?php _e('Use only in custom post types?', 'yasr'); ?> </strong> <br /> <input type="radio" name="yasr_general_options[auto_insert_custom_post_only]" value="yes" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_custom_post_only'] === 'yes') { echo " checked=\"checked\" "; } ?> > <?php _e('Yes', 'yasr'); ?> <input type="radio" name="yasr_general_options[auto_insert_custom_post_only]" value="no" class="yasr-auto-insert-options-class" <?php if ($option['auto_insert_custom_post_only'] === 'no') { echo " checked=\"checked\" "; } ?> > <?php _e('No', 'yasr'); ?> <p> <?php _e("You see this because you use custom post types.", "yasr"); ?> <br/> <?php _e("If you want to use auto insert only in custom post types, choose Yes", "yasr"); ?> <p> </p> <?php } else { ?> <input type="hidden" name="yasr_general_options[auto_insert_custom_post_only]" value="no" ?> <?php } ?> <hr /> <?php }