function rtp_display_to_content($content) { $rtp_options = get_option('aft_options_array'); $rtp_options_by = get_option('aft_options_by_array'); $is_enable = $rtp_options['aft_is_enable']; $location = $rtp_options['aft_location']; $insertion = $rtp_options['aft_insertion']; $use_shortcode = intval($rtp_options['rtp_use_shortcode']); $options_category = $rtp_options_by['category']; $options_page = $rtp_options_by['page']; // This part will display the plugin together with the content. if ($use_shortcode == 0) { $display = rtp_display_template(); } else { add_shortcode('rate_this_page', 'rtp_shortcode'); } // Register shortcode. $display_content = $content; if ($is_enable == 'true' && rtp_can_rate()) { $cat_opt_id = array(); $page_opt_id = array(); if ($insertion == 'by-category') { // Show plugin by category foreach ($options_category as $category) { if ($category > 0) { $cat_opt_id[] = intval($category); } } if (is_single() && in_category($cat_opt_id)) { if ($location == 'bottom') { $display_content = $content . $display; // Below the content } else { $display_content = $display . $content; // Above the content } } } else { if ($insertion == 'by-page') { // Show plugin by page foreach ($options_page as $page) { if ($page > 0) { $page_opt_id[] = $page; } } // To avoid displaying the plugin in all page if page_opt_id is null. if (count($page_opt_id) == 0) { $page_opt_id = 'no data'; } if (is_page($page_opt_id)) { if ($location == 'bottom') { $display_content = $content . $display; // Below the content } else { $display_content = $display . $content; // Above the content } } } else { if ($insertion == 'page-category') { // Show plugin by page and category foreach ($options_category as $category) { if ($category > 0) { $cat_opt_id[] = intval($category); } } foreach ($options_page as $page) { if ($page > 0) { $page_opt_id[] = $page; } } // To avoid displaying the plugin in all page if page_opt_id is null. if (count($page_opt_id) == 0) { $page_opt_id = 'no data'; } if (is_single() && in_category($cat_opt_id) || is_page($page_opt_id)) { if ($location == 'bottom') { $display_content = $content . $display; // Below the content } else { $display_content = $display . $content; // Above the content } } } else { // Show in all article if (is_single()) { if ($location == 'bottom') { $display_content = $content . $display; // Below the content } else { $display_content = $display . $content; // Above the content } } } } } } return $display_content; }
function rtp_shortcode() { if (is_single() || is_page()) { return rtp_display_template(); } }