function ce_display_widget_area()
{
    if (is_active_sidebar('ceprograms-widget-area')) {
        if (is_singular(CE_Plugin_Settings::get_ce_post_type())) {
            dynamic_sidebar('ceprograms-widget-area');
        }
    }
}
 private static function cecf_call_data_url($data_url)
 {
     $user_key = base64_encode(CE_Plugin_Settings::get_user_key());
     //encode user key
     $output = null;
     try {
         //use cURL to contact server and get response with data
         $ch = curl_init($data_url);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('UserKey:' . $user_key));
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($ch);
         $output1 = curl_close($ch);
         $output = simplexml_load_string($output);
     } catch (Exception $e) {
         trigger_error("Unable to retrieve information from data source.");
     }
     return $output;
 }
 function widget($args, $instance)
 {
     $post_type = get_post_type();
     $custompress_post_type = CE_Plugin_Settings::get_ce_post_type();
     if (isset($post_type) && isset($custompress_post_type) && $post_type == $custompress_post_type) {
         extract($args);
         // these are the widget options
         $ce_widget_title = apply_filters('widget_title', $instance['ce_widget_title']);
         $ce_no_of_posts = $instance['ce_no_of_posts'];
         //echo $ce_no_of_posts;
         $custom_post_id = get_the_ID();
         if (!$custom_post_id) {
             die("Posts cannot be displayed");
         }
         $custompress_taxonomy = CE_Plugin_Settings::get_ce_taxonomy();
         //echo $custompress_taxonomy;
         $terms_for_custom_post = wp_get_post_terms($custom_post_id, $custompress_taxonomy);
         if (isset($terms_for_custom_post) && !empty($terms_for_custom_post)) {
             // Display the widget
             $content = "";
             $content .= '<div class="wp-widget wp-widget-global widget_recent_entries">';
             // Check if contact title is set
             if ($ce_widget_title) {
                 $content .= "<h2 class='widget-title content-padding'>" . $ce_widget_title . "</h2>";
             }
             $content .= "<ul class='latest-posts'>";
             $the_query = new WP_Query(array('post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC'));
             $all_posts = $the_query->get_posts();
             //Display posts
             $count_matched_posts = 0;
             foreach ($all_posts as $post) {
                 //var_dump($post);
                 $post_terms = wp_get_post_terms($post->ID, $custompress_taxonomy);
                 for ($i = 0; $i < count($post_terms); $i++) {
                     for ($j = 0; $j < count($terms_for_custom_post); $j++) {
                         if (isset($post_terms[$i]->term_id) && isset($terms_for_custom_post[$j]->term_id)) {
                             if ($post_terms[$i]->term_id == $terms_for_custom_post[$j]->term_id) {
                                 $link = get_permalink($post->ID);
                                 $title = $post->post_title;
                                 $content .= "<li><a href='{$link}' target='_top'>{$title} </a </li>\n";
                                 $count_matched_posts++;
                                 //$content .= "<p class='excerpt'>" . get_the_excerpt() . "</p>";
                             }
                         }
                         if ($count_matched_posts >= $ce_no_of_posts) {
                             break 3;
                         }
                     }
                 }
                 // end of for
             }
             // end of foreach
             $content .= "</ul> </div>";
             wp_reset_query();
             //endif;
             if ($count_matched_posts != 0) {
                 echo $content;
             }
         }
         ?>
    
     <?php 
         //echo $after_widget;
     }
     // end of post_type if statement
 }