Exemple #1
0
 public function __construct($file_loc, $text_domain) {
     //$this->op = get_option('itgdb_iwiform_op');
     self::$abs_path = dirname($file_loc);
     self::$abs_file = $file_loc;
     self::$text_domain = $text_domain;
     self::$version = '2.0.3';
 }
 public function widget_output_gen($op, $cat_id, &$i)
 {
     $wp_cat_list_itg_tans = itgdb_wp_cpl_loader::$text_domain;
     $post_output = '';
     /**
      * Set the before post list HTML
      */
     $before_link = true == $op['list_style'] ? '<li class="%list_class%">' : $op['before_link'];
     $after_link = true == $op['list_style'] ? '</li>' : $op['after_link'];
     /** Calculate stick posts and excluded posts */
     $wp_cpl_sticky = wp_parse_id_list($op['sticky_post']);
     $wp_cpl_exclude = wp_parse_id_list($op['exclude_post']);
     /** First get the Sticky posts */
     if (count($wp_cpl_sticky)) {
         $wp_cpl_post_sticky = $this->get_posts(array('post__in' => $wp_cpl_sticky));
         /** Loop through the sticky posts */
         foreach ($wp_cpl_post_sticky as $post) {
             /** Initiate the post list widget HTML */
             $default_class = 'wp-cpl-sticky';
             $post_output .= str_ireplace('%list_class%', "{$default_class}", $before_link);
             /** is thumbnail? */
             $post_output .= true == $op['is_thumb'] && '' != ($wp_cpl_post_thumb = get_the_post_thumbnail($post->ID, 'wp-cpl-post-thumb')) ? '<span class="wp-thumb-overlay"><span class="' . $op['thumb_class'] . '"><a href="' . get_permalink($post->ID) . '">' . $wp_cpl_post_thumb . '</span></span>' : '';
             /** Add up the actual permalink and post title */
             $post_output .= '<a href="' . get_permalink($post->ID) . '" title="' . __('Permalink to: ', $wp_cat_list_itg_tans) . $post->post_title . '" target="' . (false == $op['open_in'] ? '_blank' : '_self') . '">' . $post->post_title . '</a>';
             /** Show comments? */
             $post_output .= true == $op['show_comments'] ? ' <span class="wp-cpl-comment"><a href="' . get_comments_link($post->ID) . '">' . $post->comment_count . ' ' . __ngettext('Comment', 'Comments', $post->comment_count, $wp_cat_list_itg_tans) . '</a></span>' : '';
             /** Add date? */
             $post_output .= true == $op['show_date'] ? ' <span class="wp-cpl-date">' . __('Posted on: ', $wp_cat_list_itg_tans) . date('M jS, Y', strtotime($post->post_date)) . '</span>' : '';
             /** Add author? */
             $post_output .= true == $op['show_author'] ? ' <span class="wp-cpl-author">' . __('By ', $wp_cat_list_itg_tans) . '<a href="' . get_the_author_meta('user_url', $post->post_author) . '">' . get_the_author_meta('display_name', $post->post_author) . '</a></span>' : '';
             /** Add excerpt? */
             $post_output .= true == $op['show_excerpt'] ? '<p class="wp-cpl-excerpt">' . (true == $op['optional_excerpt'] && $post->post_excerpt != '' ? $post->post_excerpt : itgdb_wp_cpl_loader::shorten_string($post->post_content, $op['excerpt_length'])) . '</p>' : '';
             /** Done. Now close the Widget */
             $post_output .= $after_link . "\n";
         }
     }
     /**
      * Merge the sticky and exclude posts array
      * So no duplicate post is shown
      */
     $wp_cpl_exclude = array_merge($wp_cpl_sticky, $wp_cpl_exclude);
     $wp_cpl_exclude = array_unique($wp_cpl_exclude);
     /** Set the arguments of the get_posts function */
     $get_posts_args = array('list_num' => $op['list_num'], 'sort_using' => $op['sort_using'], 'sort_order' => $op['sort_order'], 'exclude' => $wp_cpl_exclude);
     /** Actually get the post */
     $wp_cpl_posts = $this->get_posts($get_posts_args, $cat_id);
     /**
      * Free memory from unneeded variables
      * @since 1.1.0
      */
     unset($wp_cpl_sticky);
     unset($wp_cpl_exclude);
     unset($wp_cpl_post_sticky);
     unset($wp_cpl_sort_array);
     unset($get_posts_args);
     /** Loop through the posts */
     $i = 0;
     foreach ($wp_cpl_posts as $post) {
         /** Initiate the post list widget HTML */
         $default_class = true == $op['alternate_list_css'] ? $i % 2 == 0 ? 'wp-cpl wp-cpl-even' : 'wp-cpl wp-cpl-odd' : 'wp-cpl';
         $post_output .= str_ireplace('%list_class%', "{$default_class}", $before_link);
         /** is thumbnail? */
         $post_output .= true == $op['is_thumb'] && '' != ($wp_cpl_post_thumb = get_the_post_thumbnail($post->ID, 'wp-cpl-post-thumb')) ? '<span class="wp-thumb-overlay"><span class="' . $op['thumb_class'] . '"><a href="' . get_permalink($post->ID) . '">' . $wp_cpl_post_thumb . '</a></span></span>' : '';
         /** Add up the actual permalink and post title */
         $post_output .= '<a href="' . get_permalink($post->ID) . '" title="' . __('Permalink to: ', 'wp-cat-list-itg') . $post->post_title . '" target="' . (false == $op['open_in'] ? '_blank' : '_self') . '">' . $post->post_title . '</a>';
         /** Show comments? */
         $post_output .= true == $op['show_comments'] ? ' <span class="wp-cpl-comment"><a href="' . get_comments_link($post->ID) . '">' . $post->comment_count . ' ' . __ngettext('Comment', 'Comments', $post->comment_count, 'wp-cat-list-itg') . '</a></span>' : '';
         /** Add date? */
         $post_output .= true == $op['show_date'] ? ' <span class="wp-cpl-date">' . __('Posted on: ', $wp_cat_list_itg_tans) . date('M jS, Y', strtotime($post->post_date)) . '</span>' : '';
         /** Add author? */
         $post_output .= true == $op['show_author'] ? ' <span class="wp-cpl-author">' . __('By ', $wp_cat_list_itg_tans) . '<a href="' . get_the_author_meta('user_url', $post->post_author) . '">' . get_the_author_meta('display_name', $post->post_author) . '</a></span>' : '';
         /** Add excerpt? */
         $post_output .= true == $op['show_excerpt'] ? '<p class="wp-cpl-excerpt">' . (true == $op['optional_excerpt'] && $post->post_excerpt != '' ? $post->post_excerpt : itgdb_wp_cpl_loader::shorten_string($post->post_content, $op['excerpt_length'])) . '</p>' : '';
         /** Done. Now close the Widget */
         $post_output .= $after_link . "\n";
         $i++;
     }
     return $post_output;
 }
 * @todo Post date and author DONE
 * @todo Add excerpt support DONE
 * @todo Add hyperlink to title DONE
 * @todo Add Current post category selection support DONE
 * @todo Efficient read more and feed link with html support DONE
 * @todo Add tabbed widget support 2 | 3 tab
 * @todo Add multiple category to shortcode
 * @todo add filters for custom css theme DONE
 */
/** Todo list as of development 2.1.0
 * @todo Fix strip shortcode from the custom excerpt
 * @todo Add tabbed widget support
 * @todo Add multiple category selection support
 * @todo Add CSS3 themes (5)
 * @todo Add pagination support for shortcode
 * @todo Add custom field sorting
 */
/**
 * Include the loader
 */
include_once dirname(__FILE__) . '/classes/loader.php';
$itgdb_wp_cpl_plugin = new itgdb_wp_cpl_loader(__FILE__, $text_domain);
/**
 * Include common files
 */
include_once itgdb_wp_cpl_loader::$abs_path . '/includes/wp_cpl_css_filters.php';
include_once itgdb_wp_cpl_loader::$abs_path . '/includes/wp_cpl_widget.php';
/**
 * Ignite
 */
$itgdb_wp_cpl_plugin->load();
Exemple #4
0
 /**
  * The save options function
  */
 function update($new_instance, $old_instance)
 {
     /** Set the previous value */
     $instance = $old_instance;
     /** Extract the current values for shortcut */
     extract($new_instance);
     /** Sanitize the inputs properly */
     $instance['title'] = strip_tags($title);
     $instance['teaser'] = strip_tags($teaser);
     $instance['cat_id'] = (int) $cat_id;
     $instance['css_theme'] = $css_theme;
     $instance['show_feed'] = (bool) $show_feed;
     $instance['show_read_more'] = (bool) $show_read_more;
     $instance['feed_html'] = wp_kses_data($feed_html);
     $instance['read_more_html'] = wp_kses_data($read_more_html);
     $instance['is_thumb'] = (bool) $is_thumb;
     $instance['thumb_class'] = strip_tags($thumb_class);
     $instance['list_num'] = (int) $list_num;
     $instance['widget_class'] = strip_tags($widget_class);
     $instance['list_style'] = (bool) $list_style;
     $instance['show_comments'] = (bool) $show_comments;
     $instance['sort_using'] = (int) $sort_using;
     $instance['sort_order'] = (bool) $sort_order;
     $instance['before_main_widget'] = $before_main_widget;
     $instance['after_main_widget'] = $after_main_widget;
     $instance['before_link'] = $before_link;
     $instance['after_link'] = $after_link;
     $instance['exclude_post'] = strip_tags($exclude_post);
     $instance['sticky_post'] = strip_tags($sticky_post);
     $instance['open_in'] = (bool) $open_in;
     $instance['alternate_list_css'] = (bool) $alternate_list_css;
     $instance['show_date'] = (bool) $show_date;
     $instance['show_author'] = (bool) $show_author;
     $instance['show_excerpt'] = (bool) $show_excerpt;
     $instance['excerpt_length'] = (int) $excerpt_length;
     $instance['optional_excerpt'] = (bool) $optional_excerpt;
     $instance['title_hyper'] = (bool) $title_hyper;
     /**
      * Little negative fix for excerpt_length and list_num
      * @since 1.1.0
      */
     if ($instance['list_num'] < 0) {
         $instance['list_num'] = $instance['list_num'] * -1;
     }
     if ($instance['excerpt_length'] < 0) {
         $instance['excerpt_length'] = $instance['excerpt_length'] * -1;
     }
     /** Delete the previous cache */
     wp_cache_delete($this->id);
     /** Check for any error */
     /** Reset the error first */
     $instance['error'] = false;
     /** Now search for possibilities */
     if ($instance['title'] == '') {
         $instance_error .= '<li>&rarr;' . __('<strong style="color: red">Error</strong>: The Title field is empty', 'wp-cat-list-itg') . '</li>';
     }
     if ($instance['cat_id'] != -1 && !category_exists($instance['cat_id'])) {
         $instance_error .= '<li>&rarr;' . __('<strong style="color: red">Error</strong>: The category does not exists', 'wp-cat-list-itg') . '</li>';
     }
     $form_cat_count = itgdb_wp_cpl_loader::wp_get_postcount($instance['cat_id']);
     if ($instance['cat_id'] != -1 && 0 == $form_cat_count) {
         $instance_error .= '<li>&rarr;' . __('<strong style="color: red">Error</strong>: The category is empty', 'wp-cat-list-itg') . '</li>';
     } else {
         if ($instance['cat_id'] != -1 && $instance['list_num'] > $form_cat_count) {
             $instance_error .= '<li>&rarr;' . __('<strong style="color: #c3bc00">Warning</strong>: The number of posts is less than your entered number. No worries though! <em>Total number of posts', 'wp-cat-list-itg') . $form_cat_count . '</em></li>';
         }
     }
     if (isset($instance_error)) {
         $instance_error = '<ul style="font-style: italic">' . $instance_error . '</ul>';
         $instance['error'] = $instance_error;
     }
     /** Return it */
     return $instance;
 }