function tab_content_html($catid = '', $start = 0, $cols = '', $max_length = 30, $caption = 'true') { $html = ''; $options = get_option('sw_tab_content'); $count_item = isset($options['count_item']) ? intval($options['count_item']) : 5; //$max_length = isset($options['max_length']) ? intval($options['max_length']) : 30; //$cols = isset($options['colums']) ? $options['colums'] : 'span6'; $posts = get_posts(array('category' => $catid, 'numberposts' => $count_item, 'offset' => $start * $count_item)); $html .= '<div class="item-inner clearfix">'; $html .= '<div class="row">'; foreach ($posts as $post) { $html .= '<div class="' . $cols . '">'; $html .= '<div class="item-content">'; $Plugin_Tab_Content = new Plugin_Tab_Content(); $options = get_option('sw_tab_content'); if (has_post_thumbnail($post->ID)) { $html .= '<div class="sw-thumb">'; $attachment_id = get_post_thumbnail_id($post->ID); $html .= '<img alt="" src="' . $Plugin_Tab_Content->sw_resize_url($attachment_id, $options) . '">'; $html .= '<div class="sw-mask"><div class="sw-mask-inner">'; if ($caption == 'true') { $html .= '<div class="sw-content">'; $html .= '<div class="sw-title"><h4><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h4></div>'; $html .= '<div class="sw-meta">'; $html .= '<span class="sw-date">' . date('d F Y', strtotime($post->post_date)) . '</span>'; $html .= '<div class="sw-category"><span class="icon-briefcase"></span>Category: ' . get_the_category_list(', ', '', $post->ID) . '</div>'; $html .= '</div>'; $html .= '<div class="sw-desc">'; $Plugin_Tab_Content = new Plugin_Tab_Content(); $html .= $Plugin_Tab_Content->sw_trim_words($post->post_content, $max_length); $html .= '<a href="' . get_permalink($post->ID) . '"> Read more</a>'; $html .= '</div>'; $html .= '</div>'; } $attachment_id = get_post_thumbnail_id($post->ID); $html .= '<a class="sw-link sw-icon" title="' . $post->post_title . '" href="' . get_permalink($post->ID) . '"><span class="icon-link"></span></a> <a class="sw-search sw-icon" title="Zoom" href="' . wp_get_attachment_url($attachment_id) . '" rel="prettyPhoto[portfolio]"><span class="icon-search"></span></a></div></div>'; $html .= '</div>'; } $html .= '</div>'; $html .= '</div>'; } $html .= '</div>'; $html .= '</div>'; return $html; }
* @package Plugin_Name * @author Your Name <*****@*****.**> * @license GPL-2.0+ * @link http://example.com * @copyright 2013 Your Name or Company Name * * @wordpress-plugin * Plugin Name: Tab Content * Plugin URI: Tab Content * Description: Tab Content * Version: 1.0.0 * Author: Tab Content * Author URI: Tab Content * Text Domain: plugin-name-locale * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Domain Path: /lang */ // If this file is called directly, abort. if (!defined('WPINC')) { die; } // TODO: replace `class-plugin-tab-content.php` with the name of the actual plugin's class file require_once plugin_dir_path(__FILE__) . 'class-plugin-tab-content.php'; // Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively. // TODO: replace Plugin_Name with the name of the plugin defined in `class-plugin-tab-content.php` register_activation_hook(__FILE__, array('Plugin_Tab_Content', 'activate')); register_deactivation_hook(__FILE__, array('Plugin_Tab_Content', 'deactivate')); // TODO: replace Plugin_Name with the name of the plugin defined in `class-plugin-tab-content.php` Plugin_Tab_Content::get_instance();
/** * Return an instance of this class. * * @since 1.0.0 * * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }