initial commit
This commit is contained in:
@ -0,0 +1,611 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions to fetch and display the posts
|
||||
*
|
||||
* @package Top_Ten
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return formatted list of popular posts.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @param mixed $args Arguments array.
|
||||
* @return string HTML output of the popular posts.
|
||||
*/
|
||||
function tptn_pop_posts( $args ) {
|
||||
global $tptn_settings;
|
||||
|
||||
// if set, save $exclude_categories.
|
||||
if ( isset( $args['exclude_categories'] ) && '' != $args['exclude_categories'] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$exclude_categories = explode( ',', $args['exclude_categories'] );
|
||||
$args['strict_limit'] = false;
|
||||
}
|
||||
|
||||
$defaults = array(
|
||||
'daily' => false,
|
||||
'is_widget' => false,
|
||||
'instance_id' => 1,
|
||||
'is_shortcode' => false,
|
||||
'is_manual' => false,
|
||||
'echo' => false,
|
||||
'strict_limit' => false,
|
||||
'heading' => 1,
|
||||
'offset' => 0,
|
||||
);
|
||||
|
||||
// Merge the $defaults array with the $tptn_settings array.
|
||||
$defaults = array_merge( $defaults, tptn_settings_defaults(), $tptn_settings );
|
||||
|
||||
// Parse incomming $args into an array and merge it with $defaults.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$output = '';
|
||||
|
||||
/**
|
||||
* Fires before the output processing begins.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $output Formatted list of top posts
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
do_action( 'pre_tptn_pop_posts', $output, $args );
|
||||
|
||||
// Check if the cache is enabled and if the output exists. If so, return the output.
|
||||
if ( $args['cache'] ) {
|
||||
$cache_name = tptn_cache_get_key( $args );
|
||||
|
||||
$output = get_transient( $cache_name );
|
||||
|
||||
if ( false !== $output ) {
|
||||
|
||||
/**
|
||||
* Filter the output
|
||||
*
|
||||
* @since 1.9.8.5
|
||||
*
|
||||
* @param string $output Formatted list of top posts
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_pop_posts', $output, $args );
|
||||
}
|
||||
}
|
||||
|
||||
// Get thumbnail size.
|
||||
list( $args['thumb_width'], $args['thumb_height'] ) = tptn_get_thumb_size( $args );
|
||||
|
||||
// Retrieve the popular posts.
|
||||
$results = get_tptn_posts( $args );
|
||||
|
||||
$counter = 0;
|
||||
|
||||
$daily_class = $args['daily'] ? 'tptn_posts_daily ' : 'tptn_posts ';
|
||||
$widget_class = $args['is_widget'] ? ' tptn_posts_widget tptn_posts_widget' . $args['instance_id'] : '';
|
||||
$shortcode_class = $args['is_shortcode'] ? ' tptn_posts_shortcode' : '';
|
||||
|
||||
$post_classes = $daily_class . $widget_class . $shortcode_class;
|
||||
|
||||
/**
|
||||
* Filter the classes added to the div wrapper of the Top 10.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $post_classes Post classes string.
|
||||
*/
|
||||
$post_classes = apply_filters( 'tptn_post_class', $post_classes );
|
||||
|
||||
$output .= '<div class="' . $post_classes . '">';
|
||||
|
||||
if ( $results ) {
|
||||
|
||||
$output .= tptn_heading_title( $args );
|
||||
|
||||
$output .= tptn_before_list( $args );
|
||||
|
||||
// We need this for WPML support.
|
||||
$processed_results = array();
|
||||
|
||||
foreach ( $results as $result ) {
|
||||
|
||||
/* Support WPML */
|
||||
$resultid = tptn_object_id_cur_lang( $result->ID );
|
||||
|
||||
// If this is NULL or already processed ID or matches current post then skip processing this loop.
|
||||
if ( ! $resultid || in_array( $resultid, $processed_results ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
continue;
|
||||
}
|
||||
|
||||
// Push the current ID into the array to ensure we're not repeating it.
|
||||
array_push( $processed_results, $resultid );
|
||||
|
||||
// Store the count. We'll need this later.
|
||||
$count = $args['daily'] ? 'daily' : 'total';
|
||||
$visits = empty( $result->visits ) ? get_tptn_post_count_only( $resultid, $count ) : $result->visits;
|
||||
|
||||
/**
|
||||
* Filter the post ID for each result. Allows a custom function to hook in and change the ID if needed.
|
||||
*
|
||||
* @since 1.9.8.5
|
||||
*
|
||||
* @param int $resultid ID of the post
|
||||
*/
|
||||
$resultid = apply_filters( 'tptn_post_id', $resultid );
|
||||
|
||||
$result = get_post( $resultid ); // Let's get the Post using the ID.
|
||||
|
||||
// Process the category exclusion if passed in the shortcode.
|
||||
if ( isset( $exclude_categories ) ) {
|
||||
|
||||
$categorys = get_the_category( $result->ID ); // Fetch categories of the plugin.
|
||||
|
||||
$p_in_c = false; // Variable to check if post exists in a particular category.
|
||||
foreach ( $categorys as $cat ) { // Loop to check if post exists in excluded category.
|
||||
$p_in_c = ( in_array( $cat->cat_ID, $exclude_categories ) ) ? true : false; // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
if ( $p_in_c ) {
|
||||
break; // Skip loop execution and go to the next step.
|
||||
}
|
||||
}
|
||||
if ( $p_in_c ) {
|
||||
continue; // Skip loop execution and go to the next step.
|
||||
}
|
||||
}
|
||||
|
||||
$output .= tptn_before_list_item( $args, $result );
|
||||
|
||||
$output .= tptn_list_link( $args, $result );
|
||||
|
||||
if ( $args['show_author'] ) {
|
||||
$output .= tptn_author( $args, $result );
|
||||
}
|
||||
|
||||
if ( $args['show_date'] ) {
|
||||
$output .= '<span class="tptn_date"> ' . tptn_date( $args, $result ) . '</span> ';
|
||||
}
|
||||
|
||||
if ( $args['show_excerpt'] ) {
|
||||
$output .= '<span class="tptn_excerpt"> ' . tptn_excerpt( $result->ID, $args['excerpt_length'] ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['disp_list_count'] ) {
|
||||
|
||||
$output .= ' <span class="tptn_list_count">' . tptn_list_count( $args, $result, $visits ) . '</span>';
|
||||
}
|
||||
|
||||
$tptn_list = '';
|
||||
/**
|
||||
* Filter to add content to the end of each item in the list.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $tptn_list Empty string at the end of each list item.
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
$output .= apply_filters( 'tptn_list', $tptn_list, $result, $args );
|
||||
|
||||
// Opening span created in tptn_list_link().
|
||||
if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
|
||||
$output .= '</span>';
|
||||
}
|
||||
|
||||
$output .= tptn_after_list_item( $args, $result );
|
||||
|
||||
$counter++;
|
||||
|
||||
if ( $counter === (int) $args['limit'] ) {
|
||||
break; // End loop when related posts limit is reached.
|
||||
}
|
||||
}
|
||||
if ( $args['show_credit'] ) {
|
||||
|
||||
$output .= tptn_before_list_item( $args, $result );
|
||||
|
||||
$output .= sprintf(
|
||||
/* translators: 1. Top 10 plugin page link, 2. Link attributes. */
|
||||
__( 'Popular posts by <a href="%1$s" rel="nofollow" %2$s>Top 10 plugin</a>', 'top-10' ),
|
||||
esc_url( 'https://webberzone.com/plugins/top-10/' ),
|
||||
tptn_link_attributes( $args, $result )
|
||||
);
|
||||
|
||||
$output .= tptn_after_list_item( $args, $result );
|
||||
}
|
||||
|
||||
$output .= tptn_after_list( $args );
|
||||
|
||||
$clearfix = '<div class="tptn_clear"></div>';
|
||||
|
||||
/**
|
||||
* Filter the clearfix div tag. This is included after the closing tag to clear any miscellaneous floating elements;
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $clearfix Contains: <div style="clear:both"></div>
|
||||
*/
|
||||
$output .= apply_filters( 'tptn_clearfix', $clearfix );
|
||||
|
||||
} else {
|
||||
$output .= ( $args['blank_output'] ) ? '' : $args['blank_output_text'];
|
||||
}
|
||||
$output .= '</div>';
|
||||
|
||||
// Check if the cache is enabled and if the output exists. If so, return the output.
|
||||
if ( $args['cache'] ) {
|
||||
/**
|
||||
* Filter the cache time which allows a function to override this
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param int $args['cache_time'] Cache time in seconds
|
||||
* @param array $args Array of all the arguments
|
||||
*/
|
||||
$cache_time = apply_filters( 'tptn_cache_time', $args['cache_time'], $args );
|
||||
|
||||
$output .= "<br /><!-- Cached output. Cached time is {$cache_time} seconds -->";
|
||||
|
||||
set_transient( $cache_name, $output, $cache_time );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter already documented in top-10.php
|
||||
*/
|
||||
return apply_filters( 'tptn_pop_posts', $output, $args );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to retrieve the popular posts.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param mixed $args Arguments list.
|
||||
*/
|
||||
function get_tptn_pop_posts( $args = array() ) {
|
||||
global $wpdb, $tptn_settings;
|
||||
|
||||
// Initialise some variables.
|
||||
$fields = array();
|
||||
$where = '';
|
||||
$join = '';
|
||||
$groupby = '';
|
||||
$orderby = '';
|
||||
$limits = '';
|
||||
|
||||
$defaults = array(
|
||||
'daily' => false,
|
||||
'strict_limit' => true,
|
||||
'posts_only' => false,
|
||||
'offset' => 0,
|
||||
);
|
||||
|
||||
// Merge the $defaults array with the $tptn_settings array.
|
||||
$defaults = array_merge( $defaults, tptn_settings_defaults(), $tptn_settings );
|
||||
|
||||
// Parse incomming $args into an array and merge it with $defaults.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
if ( $args['daily'] ) {
|
||||
$table_name = $wpdb->base_prefix . 'top_ten_daily';
|
||||
} else {
|
||||
$table_name = $wpdb->base_prefix . 'top_ten';
|
||||
}
|
||||
|
||||
$limit = ( $args['strict_limit'] ) ? $args['limit'] : ( $args['limit'] * 5 );
|
||||
$offset = isset( $args['offset'] ) ? $args['offset'] : 0;
|
||||
|
||||
// If post_types is empty or contains a query string then use parse_str else consider it comma-separated.
|
||||
if ( ! empty( $args['post_types'] ) && is_array( $args['post_types'] ) ) {
|
||||
$post_types = $args['post_types'];
|
||||
} elseif ( ! empty( $args['post_types'] ) && false === strpos( $args['post_types'], '=' ) ) {
|
||||
$post_types = explode( ',', $args['post_types'] );
|
||||
} else {
|
||||
parse_str( $args['post_types'], $post_types ); // Save post types in $post_types variable.
|
||||
}
|
||||
|
||||
// If post_types is empty or if we want all the post types.
|
||||
if ( empty( $post_types ) || 'all' === $args['post_types'] ) {
|
||||
$post_types = get_post_types(
|
||||
array(
|
||||
'public' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$blog_id = get_current_blog_id();
|
||||
|
||||
$from_date = tptn_get_from_date( null, $args['daily_range'], $args['hour_range'] );
|
||||
|
||||
/**
|
||||
*
|
||||
* We're going to create a mySQL query that is fully extendable which would look something like this:
|
||||
* "SELECT $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"
|
||||
*/
|
||||
|
||||
// Fields to return.
|
||||
$fields[] = "{$table_name}.postnumber";
|
||||
$fields[] = ( $args['daily'] ) ? "SUM({$table_name}.cntaccess) as visits" : "{$table_name}.cntaccess as visits";
|
||||
$fields[] = "{$wpdb->posts}.ID";
|
||||
|
||||
$fields = implode( ', ', $fields );
|
||||
|
||||
// Create the JOIN clause.
|
||||
$join = " INNER JOIN {$wpdb->posts} ON {$table_name}.postnumber={$wpdb->posts}.ID ";
|
||||
|
||||
// Create the base WHERE clause.
|
||||
$where .= $wpdb->prepare( " AND {$table_name}.blog_id = %d ", $blog_id ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$where .= " AND ({$wpdb->posts}.post_status = 'publish' OR {$wpdb->posts}.post_status = 'inherit') "; // Show published posts and attachments.
|
||||
|
||||
if ( $args['daily'] ) {
|
||||
$where .= $wpdb->prepare( " AND {$table_name}.dp_date >= %s ", $from_date ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
}
|
||||
|
||||
// Convert exclude post IDs string to array so it can be filtered.
|
||||
$exclude_post_ids = explode( ',', $args['exclude_post_ids'] );
|
||||
|
||||
/** This filter is documented in class-top-ten-query.php */
|
||||
$exclude_post_ids = apply_filters( 'tptn_exclude_post_ids', $exclude_post_ids );
|
||||
|
||||
// Convert it back to string.
|
||||
$exclude_post_ids = implode( ',', array_filter( $exclude_post_ids ) );
|
||||
|
||||
if ( '' != $exclude_post_ids ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$where .= " AND $wpdb->posts.ID NOT IN ({$exclude_post_ids}) ";
|
||||
}
|
||||
$where .= " AND $wpdb->posts.post_type IN ('" . join( "', '", $post_types ) . "') "; // Array of post types.
|
||||
|
||||
// How old should the posts be?
|
||||
if ( $args['how_old'] ) {
|
||||
$how_old_date = tptn_get_from_date( null, $args['how_old'] + 1, 0 );
|
||||
|
||||
$where .= $wpdb->prepare( " AND $wpdb->posts.post_date > %s ", $how_old_date );
|
||||
}
|
||||
|
||||
if ( isset( $args['include_cat_ids'] ) && ! empty( $args['include_cat_ids'] ) ) {
|
||||
$include_cat_ids = $args['include_cat_ids'];
|
||||
|
||||
$where .= " AND $wpdb->posts.ID IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ($include_cat_ids) )";
|
||||
}
|
||||
|
||||
// Create the base GROUP BY clause.
|
||||
if ( $args['daily'] ) {
|
||||
$groupby = ' postnumber ';
|
||||
}
|
||||
|
||||
// Create the base ORDER BY clause.
|
||||
$orderby = ' visits DESC ';
|
||||
|
||||
// Create the base LIMITS clause.
|
||||
$limits .= $wpdb->prepare( ' LIMIT %d, %d ', $offset, $limit );
|
||||
|
||||
/**
|
||||
* Filter the SELECT clause of the query.
|
||||
*
|
||||
* @param string $fields The SELECT clause of the query.
|
||||
*/
|
||||
$fields = apply_filters( 'tptn_posts_fields', $fields );
|
||||
|
||||
/**
|
||||
* Filter the JOIN clause of the query.
|
||||
*
|
||||
* @param string $join The JOIN clause of the query.
|
||||
*/
|
||||
$join = apply_filters( 'tptn_posts_join', $join );
|
||||
|
||||
/**
|
||||
* Filter the WHERE clause of the query.
|
||||
*
|
||||
* @param string $where The WHERE clause of the query.
|
||||
*/
|
||||
$where = apply_filters( 'tptn_posts_where', $where );
|
||||
|
||||
/**
|
||||
* Filter the GROUP BY clause of the query.
|
||||
*
|
||||
* @param string $groupby The GROUP BY clause of the query.
|
||||
*/
|
||||
$groupby = apply_filters( 'tptn_posts_groupby', $groupby );
|
||||
|
||||
/**
|
||||
* Filter the ORDER BY clause of the query.
|
||||
*
|
||||
* @param string $orderby The ORDER BY clause of the query.
|
||||
*/
|
||||
$orderby = apply_filters( 'tptn_posts_orderby', $orderby );
|
||||
|
||||
/**
|
||||
* Filter the LIMIT clause of the query.
|
||||
*
|
||||
* @param string $limits The LIMIT clause of the query.
|
||||
*/
|
||||
$limits = apply_filters( 'tptn_posts_limits', $limits );
|
||||
|
||||
if ( ! empty( $groupby ) ) {
|
||||
$groupby = " GROUP BY {$groupby} ";
|
||||
}
|
||||
if ( ! empty( $orderby ) ) {
|
||||
$orderby = " ORDER BY {$orderby} ";
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT $fields FROM {$table_name} $join WHERE 1=1 $where $groupby $orderby $limits";
|
||||
|
||||
if ( $args['posts_only'] ) { // Return the array of posts only if the variable is set.
|
||||
$results = $wpdb->get_results( $sql, ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
|
||||
|
||||
/**
|
||||
* Filter the array of top post IDs.
|
||||
*
|
||||
* @since 1.9.8.5
|
||||
*
|
||||
* @param array $tptn_pop_posts_array Posts array.
|
||||
* @param mixed $args Arguments list
|
||||
*/
|
||||
return apply_filters( 'tptn_pop_posts_array', $results, $args );
|
||||
}
|
||||
|
||||
$results = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
|
||||
|
||||
/**
|
||||
* Filter object containing post IDs of popular posts
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param object $results Top 10 popular posts object
|
||||
* @param mixed $args Arguments list
|
||||
*/
|
||||
return apply_filters( 'get_tptn_pop_posts', $results, $args );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to echo popular posts.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param mixed $args Arguments list.
|
||||
*/
|
||||
function tptn_show_pop_posts( $args = null ) {
|
||||
if ( is_array( $args ) ) {
|
||||
$args['manual'] = 1;
|
||||
} else {
|
||||
$args .= '&is_manual=1';
|
||||
}
|
||||
|
||||
echo tptn_pop_posts( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to show daily popular posts.
|
||||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @param mixed $args Arguments list.
|
||||
*/
|
||||
function tptn_show_daily_pop_posts( $args = null ) {
|
||||
if ( is_array( $args ) || ! isset( $args ) ) {
|
||||
$args['daily'] = 1;
|
||||
} else {
|
||||
$args .= '&daily=1';
|
||||
}
|
||||
|
||||
tptn_show_pop_posts( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom feeds for the overall and daily popular posts.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tptn_pop_posts_feed() {
|
||||
|
||||
$popular_posts_overall = tptn_get_option( 'feed_permalink_overall' );
|
||||
$popular_posts_daily = tptn_get_option( 'feed_permalink_daily' );
|
||||
|
||||
if ( ! empty( $popular_posts_overall ) ) {
|
||||
add_feed( $popular_posts_overall, 'tptn_pop_posts_feed_overall' );
|
||||
}
|
||||
if ( ! empty( $popular_posts_daily ) ) {
|
||||
add_feed( $popular_posts_daily, 'tptn_pop_posts_feed_daily' );
|
||||
}
|
||||
|
||||
}
|
||||
add_action( 'init', 'tptn_pop_posts_feed' );
|
||||
|
||||
/**
|
||||
* Callback for overall popular posts.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tptn_pop_posts_feed_overall() {
|
||||
tptn_pop_posts_feed_callback( false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for daily popular posts.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tptn_pop_posts_feed_daily() {
|
||||
tptn_pop_posts_feed_callback( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for add_feed to locate the correct template.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param bool $daily Daily posts flag.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tptn_pop_posts_feed_callback( $daily = false ) {
|
||||
add_filter( 'pre_option_rss_use_excerpt', '__return_zero' );
|
||||
|
||||
set_query_var( 'daily', $daily );
|
||||
|
||||
$template = locate_template( 'feed-rss2-popular-posts.php' );
|
||||
|
||||
if ( ! $template ) {
|
||||
$template = TOP_TEN_PLUGIN_DIR . 'includes/public/feed-rss2-popular-posts.php';
|
||||
}
|
||||
|
||||
if ( $template ) {
|
||||
load_template( $template );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the key based on a list of parameters.
|
||||
*
|
||||
* @since 2.9.3
|
||||
*
|
||||
* @param array $attr Array of attributes.
|
||||
* @return string Cache key
|
||||
*/
|
||||
function tptn_cache_get_key( $attr ) {
|
||||
|
||||
$key = 'tptn_cache_' . md5( wp_json_encode( $attr ) );
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an array of the related posts.
|
||||
*
|
||||
* The defaults are as follows:
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Top_Ten_Query::prepare_query_args()
|
||||
*
|
||||
* @param array $args Optional. Arguments to retrieve posts. See WP_Query::parse_query() for all available arguments.
|
||||
* @return WP_Post[]|int[] Array of post objects or post IDs.
|
||||
*/
|
||||
function get_tptn_posts( $args = array() ) {
|
||||
|
||||
$get_tptn_posts = new Top_Ten_Query( $args );
|
||||
|
||||
/**
|
||||
* Filter array of post IDs or objects.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param WP_Post[]|int[] $posts Array of post objects or post IDs.
|
||||
* @param array $args Arguments to retrieve posts.
|
||||
*/
|
||||
return apply_filters( 'get_tptn_posts', $get_tptn_posts->posts, $args );
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* RSS2 Feed Template for displaying RSS2 Posts feed for the Top 10 Popular posts.
|
||||
*
|
||||
* @package TOP_TEN
|
||||
*/
|
||||
|
||||
$settings = array(
|
||||
'daily' => $daily,
|
||||
'daily_range' => tptn_get_option( 'feed_daily_range' ),
|
||||
'limit' => tptn_get_option( 'feed_limit' ),
|
||||
);
|
||||
$topposts = get_tptn_posts( $settings );
|
||||
|
||||
$topposts = wp_list_pluck( (array) $topposts, 'postnumber' );
|
||||
|
||||
$args = array(
|
||||
'post__in' => $topposts,
|
||||
'orderby' => 'post__in',
|
||||
'posts_per_page' => count( $topposts ),
|
||||
);
|
||||
|
||||
query_posts( $args ); // phpcs:ignore WordPress.WP.DiscouragedFunctions.query_posts_query_posts
|
||||
|
||||
header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=' . get_option( 'blog_charset' ), true );
|
||||
$more = 1; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
|
||||
echo '<?xml version="1.0" encoding="' . esc_attr( get_option( 'blog_charset' ) ) . '"?' . '>';
|
||||
|
||||
/**
|
||||
* Fires between the xml and rss tags in a feed.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments',
|
||||
* 'rdf', 'atom', and 'atom-comments'.
|
||||
*/
|
||||
do_action( 'rss_tag_pre', 'rss2' );
|
||||
?>
|
||||
<rss version="2.0"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
||||
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
|
||||
<?php
|
||||
/**
|
||||
* Fires at the end of the RSS root to add namespaces.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
do_action( 'rss2_ns' );
|
||||
?>
|
||||
>
|
||||
|
||||
<channel>
|
||||
<title><?php wp_title_rss(); ?></title>
|
||||
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
||||
<link><?php bloginfo_rss( 'url' ); ?></link>
|
||||
<description><?php bloginfo_rss( 'description' ); ?></description>
|
||||
<lastBuildDate><?php echo get_feed_build_date( 'r' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></lastBuildDate>
|
||||
<language><?php bloginfo_rss( 'language' ); ?></language>
|
||||
<sy:updatePeriod>
|
||||
<?php
|
||||
$duration = 'hourly';
|
||||
|
||||
/**
|
||||
* Filters how often to update the RSS feed.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
|
||||
* 'yearly'. Default 'hourly'.
|
||||
*/
|
||||
echo apply_filters( 'rss_update_period', $duration ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
?>
|
||||
</sy:updatePeriod>
|
||||
<sy:updateFrequency>
|
||||
<?php
|
||||
$frequency = '1';
|
||||
|
||||
/**
|
||||
* Filters the RSS update frequency.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $frequency An integer passed as a string representing the frequency
|
||||
* of RSS updates within the update period. Default '1'.
|
||||
*/
|
||||
echo apply_filters( 'rss_update_frequency', $frequency ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
?>
|
||||
</sy:updateFrequency>
|
||||
<?php
|
||||
/**
|
||||
* Fires at the end of the RSS2 Feed Header.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
do_action( 'rss2_head' );
|
||||
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
?>
|
||||
<item>
|
||||
<title><?php the_title_rss(); ?></title>
|
||||
<link><?php the_permalink_rss(); ?></link>
|
||||
<?php if ( get_comments_number() || comments_open() ) : ?>
|
||||
<comments><?php comments_link_feed(); ?></comments>
|
||||
<?php endif; ?>
|
||||
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></pubDate>
|
||||
<dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator>
|
||||
<?php the_category_rss( 'rss2' ); ?>
|
||||
|
||||
<guid isPermaLink="false"><?php the_guid(); ?></guid>
|
||||
<?php if ( get_option( 'rss_use_excerpt' ) ) : ?>
|
||||
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
|
||||
<?php else : ?>
|
||||
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
|
||||
<?php $content = get_the_content_feed( 'rss2' ); ?>
|
||||
<?php if ( strlen( $content ) > 0 ) : ?>
|
||||
<content:encoded><![CDATA[<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>]]></content:encoded>
|
||||
<?php else : ?>
|
||||
<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ( get_comments_number() || comments_open() ) : ?>
|
||||
<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss>
|
||||
<slash:comments><?php echo get_comments_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></slash:comments>
|
||||
<?php endif; ?>
|
||||
<?php rss_enclosure(); ?>
|
||||
<?php
|
||||
/**
|
||||
* Fires at the end of each RSS2 feed item.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
do_action( 'rss2_item' );
|
||||
?>
|
||||
</item>
|
||||
<?php endwhile; ?>
|
||||
</channel>
|
||||
</rss>
|
@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
@ -0,0 +1,543 @@
|
||||
<?php
|
||||
/**
|
||||
* Media handler
|
||||
*
|
||||
* @package Top_Ten
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add custom image size of thumbnail. Filters `init`.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function tptn_add_image_sizes() {
|
||||
$thumb_size = tptn_get_option( 'thumb_size' );
|
||||
|
||||
if ( ! in_array( $thumb_size, get_intermediate_image_sizes() ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
$thumb_size = 'tptn_thumbnail';
|
||||
}
|
||||
|
||||
// Add image sizes if 'tptn_thumbnail' is selected or the selected thumbnail size is no longer valid.
|
||||
if ( 'tptn_thumbnail' === $thumb_size && tptn_get_option( 'thumb_create_sizes' ) ) {
|
||||
$width = tptn_get_option( 'thumb_width', 150 );
|
||||
$height = tptn_get_option( 'thumb_height', 150 );
|
||||
$crop = tptn_get_option( 'thumb_crop', true );
|
||||
|
||||
add_image_size( 'tptn_thumbnail', $width, $height, $crop );
|
||||
}
|
||||
}
|
||||
add_action( 'init', 'tptn_add_image_sizes' );
|
||||
|
||||
|
||||
/**
|
||||
* Function to get the post thumbnail.
|
||||
*
|
||||
* @since 1.8
|
||||
* @param array $args Query string of options related to thumbnails.
|
||||
* @return string Image tag
|
||||
*/
|
||||
function tptn_get_the_post_thumbnail( $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
'postid' => '',
|
||||
'thumb_height' => '150', // Max height of thumbnails.
|
||||
'thumb_width' => '150', // Max width of thumbnails.
|
||||
'thumb_meta' => 'post-image', // Meta field that is used to store the location of default thumbnail image.
|
||||
'thumb_html' => 'html', // HTML / CSS for width and height attributes.
|
||||
'thumb_default' => '', // Default thumbnail image.
|
||||
'thumb_default_show' => true, // Show default thumb if none found (if false, don't show thumb at all).
|
||||
'scan_images' => false, // Scan post for images.
|
||||
'class' => 'tptn_thumb', // Class of the thumbnail.
|
||||
);
|
||||
|
||||
// Parse incomming $args into an array and merge it with $defaults.
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
// Issue notice for deprecated arguments.
|
||||
if ( isset( $args['thumb_timthumb'] ) ) {
|
||||
_deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'thumb_timthumb argument has been deprecated', 'top-10' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['thumb_timthumb_q'] ) ) {
|
||||
_deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'thumb_timthumb_q argument has been deprecated', 'top-10' ) );
|
||||
}
|
||||
|
||||
if ( isset( $args['filter'] ) ) {
|
||||
_deprecated_argument( __FUNCTION__, '2.1', esc_html__( 'filter argument has been deprecated', 'top-10' ) );
|
||||
}
|
||||
|
||||
if ( is_int( $args['postid'] ) ) {
|
||||
$result = get_post( $args['postid'] );
|
||||
} else {
|
||||
$result = $args['postid'];
|
||||
}
|
||||
|
||||
$post_title = esc_attr( $result->post_title );
|
||||
|
||||
/**
|
||||
* Filters the title and alt message for thumbnails.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param string $post_title Post tile used as thumbnail alt and title
|
||||
* @param object $result Post Object
|
||||
*/
|
||||
$post_title = apply_filters( 'tptn_thumb_title', $post_title, $result );
|
||||
|
||||
$output = '';
|
||||
$postimage = '';
|
||||
$pick = '';
|
||||
|
||||
// Let's start fetching the thumbnail. First place to look is in the post meta defined in the Settings page.
|
||||
if ( ! $postimage ) {
|
||||
$postimage = get_post_meta( $result->ID, $args['thumb_meta'], true );
|
||||
$pick = 'meta';
|
||||
if ( $postimage ) {
|
||||
$postimage_id = tptn_get_attachment_id_from_url( $postimage );
|
||||
|
||||
if ( false != wp_get_attachment_image_src( $postimage_id, array( $args['thumb_width'], $args['thumb_height'] ) ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$postthumb = wp_get_attachment_image_src( $postimage_id, array( $args['thumb_width'], $args['thumb_height'] ) );
|
||||
$postimage = $postthumb[0];
|
||||
}
|
||||
$pick .= 'correct';
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no thumbnail found, check the post thumbnail.
|
||||
if ( ! $postimage ) {
|
||||
if ( false != get_post_thumbnail_id( $result->ID ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$postthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $result->ID ), array( $args['thumb_width'], $args['thumb_height'] ) );
|
||||
|
||||
if ( false !== $postthumb ) {
|
||||
$postimage = $postthumb[0];
|
||||
$pick = 'featured';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no thumbnail found, fetch the first image in the post, if enabled.
|
||||
if ( ! $postimage && $args['scan_images'] ) {
|
||||
preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $result->post_content, $matches );
|
||||
if ( isset( $matches[1][0] ) && $matches[1][0] ) { // any image there?
|
||||
$postimage = $matches[1][0]; // we need the first one only!
|
||||
}
|
||||
$pick = 'first';
|
||||
if ( $postimage ) {
|
||||
$postimage_id = tptn_get_attachment_id_from_url( $postimage );
|
||||
|
||||
if ( false != wp_get_attachment_image_src( $postimage_id, array( $args['thumb_width'], $args['thumb_height'] ) ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$postthumb = wp_get_attachment_image_src( $postimage_id, array( $args['thumb_width'], $args['thumb_height'] ) );
|
||||
$postimage = $postthumb[0];
|
||||
$pick .= 'correct';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no thumbnail found, fetch the first child image.
|
||||
if ( ! $postimage ) {
|
||||
$postimage = tptn_get_first_image( $result->ID, $args['thumb_width'], $args['thumb_height'] ); // Get the first image.
|
||||
$pick = 'firstchild';
|
||||
}
|
||||
|
||||
// If no other thumbnail set, try to get the custom video thumbnail set by the Video Thumbnails plugin.
|
||||
if ( ! $postimage ) {
|
||||
$postimage = get_post_meta( $result->ID, '_video_thumbnail', true );
|
||||
$pick = 'video_thumb';
|
||||
}
|
||||
|
||||
// If no thumb found and settings permit, use default thumb.
|
||||
if ( ! $postimage && $args['thumb_default_show'] ) {
|
||||
$postimage = $args['thumb_default'];
|
||||
$pick = 'default_thumb';
|
||||
}
|
||||
|
||||
// Hopefully, we've found a thumbnail by now. If so, run it through the custom filter, check for SSL and create the image tag.
|
||||
if ( $postimage ) {
|
||||
|
||||
/**
|
||||
* Filters the thumbnail image URL.
|
||||
*
|
||||
* Use this filter to modify the thumbnail URL that is automatically created
|
||||
* Before v2.1 this was used for cropping the post image using timthumb
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $postimage URL of the thumbnail image
|
||||
* @param int $thumb_width Thumbnail width
|
||||
* @param int $thumb_height Thumbnail height
|
||||
* @param object $result Post Object
|
||||
*/
|
||||
$postimage = apply_filters( 'tptn_thumb_url', $postimage, $args['thumb_width'], $args['thumb_height'], $result );
|
||||
|
||||
/* Backward compatibility */
|
||||
$thumb_timthumb = false;
|
||||
$thumb_timthumb_q = 75;
|
||||
|
||||
/**
|
||||
* Filters the thumbnail image URL.
|
||||
*
|
||||
* @since 1.8.10
|
||||
* @deprecated 2.1.0 Use tptn_thumb_url instead.
|
||||
*
|
||||
* @param string $postimage URL of the thumbnail image
|
||||
* @param int $thumb_width Thumbnail width
|
||||
* @param int $thumb_height Thumbnail height
|
||||
* @param boolean $thumb_timthumb Enable timthumb?
|
||||
* @param int $thumb_timthumb_q Quality of timthumb thumbnail.
|
||||
* @param object $result Post Object
|
||||
*/
|
||||
$postimage = apply_filters( 'tptn_postimage', $postimage, $args['thumb_width'], $args['thumb_height'], $thumb_timthumb, $thumb_timthumb_q, $result );
|
||||
|
||||
if ( is_ssl() ) {
|
||||
$postimage = preg_replace( '~http://~', 'https://', $postimage );
|
||||
}
|
||||
|
||||
$class = $args['class'] . ' tptn_' . $pick;
|
||||
|
||||
/**
|
||||
* Filters the thumbnail classes and allows a filter function to add any more classes if needed.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $class Thumbnail Class
|
||||
*/
|
||||
$attr['class'] = apply_filters( 'tptn_thumb_class', $class );
|
||||
|
||||
/**
|
||||
* Filters the thumbnail alt.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $post_title Thumbnail alt attribute
|
||||
*/
|
||||
$attr['alt'] = apply_filters( 'tptn_thumb_alt', $post_title );
|
||||
|
||||
/**
|
||||
* Filters the thumbnail title.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $post_title Thumbnail title attribute
|
||||
*/
|
||||
$attr['title'] = apply_filters( 'tptn_thumb_title', $post_title );
|
||||
|
||||
$attr['thumb_html'] = $args['thumb_html'];
|
||||
$attr['thumb_width'] = $args['thumb_width'];
|
||||
$attr['thumb_height'] = $args['thumb_height'];
|
||||
|
||||
$output .= tptn_get_image_html( $postimage, $attr );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters post thumbnail created for Top 10.
|
||||
*
|
||||
* @since 1.9.10.1
|
||||
*
|
||||
* @param array $output Formatted output
|
||||
* @param array $args Argument list
|
||||
* @param string $postimage Thumbnail URL
|
||||
*/
|
||||
return apply_filters( 'tptn_get_the_post_thumbnail', $output, $args, $postimage );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an HTML img element
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $attachment_url Image URL.
|
||||
* @param array $attr Attributes for the image markup.
|
||||
* @return string HTML img element or empty string on failure.
|
||||
*/
|
||||
function tptn_get_image_html( $attachment_url, $attr = array() ) {
|
||||
|
||||
// If there is no url, return.
|
||||
if ( '' == $attachment_url ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
return;
|
||||
}
|
||||
|
||||
$default_attr = array(
|
||||
'src' => $attachment_url,
|
||||
'thumb_html' => tptn_get_option( 'thumb_html', 'html' ),
|
||||
'thumb_width' => tptn_get_option( 'thumb_width', 150 ),
|
||||
'thumb_height' => tptn_get_option( 'thumb_height', 150 ),
|
||||
);
|
||||
|
||||
$attr = wp_parse_args( $attr, $default_attr );
|
||||
|
||||
$hwstring = tptn_get_image_hwstring( $attr );
|
||||
|
||||
// Generate 'srcset' and 'sizes' if not already present.
|
||||
if ( empty( $attr['srcset'] ) ) {
|
||||
$attachment_id = tptn_get_attachment_id_from_url( $attachment_url );
|
||||
$image_meta = wp_get_attachment_metadata( $attachment_id );
|
||||
|
||||
if ( is_array( $image_meta ) ) {
|
||||
$size_array = array( absint( $attr['thumb_width'] ), absint( $attr['thumb_height'] ) );
|
||||
$srcset = wp_calculate_image_srcset( $size_array, $attachment_url, $image_meta, $attachment_id );
|
||||
$sizes = wp_calculate_image_sizes( $size_array, $attachment_url, $image_meta, $attachment_id );
|
||||
|
||||
if ( $srcset && ( $sizes || ! empty( $attr['sizes'] ) ) ) {
|
||||
$attr['srcset'] = $srcset;
|
||||
|
||||
if ( empty( $attr['sizes'] ) ) {
|
||||
$attr['sizes'] = $sizes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unset attributes we don't want to display.
|
||||
unset( $attr['thumb_html'] );
|
||||
unset( $attr['thumb_width'] );
|
||||
unset( $attr['thumb_height'] );
|
||||
|
||||
/**
|
||||
* Filters the list of attachment image attributes.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param array $attr Attributes for the image markup.
|
||||
* @param string $attachment_url Image URL.
|
||||
*/
|
||||
$attr = apply_filters( 'tptn_get_image_attributes', $attr, $attachment_url );
|
||||
$attr = array_map( 'esc_attr', $attr );
|
||||
|
||||
$html = '<img ' . $hwstring;
|
||||
foreach ( $attr as $name => $value ) {
|
||||
$html .= " $name=" . '"' . $value . '"';
|
||||
}
|
||||
$html .= ' />';
|
||||
|
||||
return apply_filters( 'tptn_get_image_html', $html );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve width and height attributes using given width and height values.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param array $args Argument array.
|
||||
*
|
||||
* @return string Height-width string.
|
||||
*/
|
||||
function tptn_get_image_hwstring( $args = array() ) {
|
||||
|
||||
$default_args = array(
|
||||
'thumb_html' => tptn_get_option( 'thumb_html', 'html' ),
|
||||
'thumb_width' => tptn_get_option( 'thumb_width', 150 ),
|
||||
'thumb_height' => tptn_get_option( 'thumb_height', 150 ),
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $default_args );
|
||||
|
||||
if ( 'css' === $args['thumb_html'] ) {
|
||||
$thumb_html = ' style="max-width:' . $args['thumb_width'] . 'px;max-height:' . $args['thumb_height'] . 'px;" ';
|
||||
} elseif ( 'html' === $args['thumb_html'] ) {
|
||||
$thumb_html = ' width="' . $args['thumb_width'] . '" height="' . $args['thumb_height'] . '" ';
|
||||
} else {
|
||||
$thumb_html = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the thumbnail HTML and allows a filter function to add any more HTML if needed.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $thumb_html Thumbnail HTML.
|
||||
* @param array $args Argument array.
|
||||
*/
|
||||
return apply_filters( 'tptn_thumb_html', $thumb_html, $args );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the first child image in the post.
|
||||
*
|
||||
* @since 1.9.8
|
||||
* @param mixed $postid Post ID.
|
||||
* @param int $thumb_width Thumb width.
|
||||
* @param int $thumb_height Thumb height.
|
||||
* @return string Location of thumbnail
|
||||
*/
|
||||
function tptn_get_first_image( $postid, $thumb_width, $thumb_height ) {
|
||||
$args = array(
|
||||
'numberposts' => 1,
|
||||
'order' => 'ASC',
|
||||
'post_mime_type' => 'image',
|
||||
'post_parent' => $postid,
|
||||
'post_status' => null,
|
||||
'post_type' => 'attachment',
|
||||
);
|
||||
|
||||
$attachments = get_children( $args );
|
||||
|
||||
if ( $attachments ) {
|
||||
foreach ( $attachments as $attachment ) {
|
||||
$image_attributes = wp_get_attachment_image_src( $attachment->ID, array( $thumb_width, $thumb_height ) ) ? wp_get_attachment_image_src( $attachment->ID, array( $thumb_width, $thumb_height ) ) : wp_get_attachment_image_src( $attachment->ID, 'full' );
|
||||
|
||||
/**
|
||||
* Filters first child attachment from the post.
|
||||
*
|
||||
* @since 1.9.10.1
|
||||
*
|
||||
* @param array $image_attributes[0] URL of the image
|
||||
* @param int $postid Post ID
|
||||
* @param int $thumb_width Thumb width
|
||||
* @param int $thumb_height Thumb height
|
||||
*/
|
||||
return apply_filters( 'tptn_get_first_image', $image_attributes[0], $postid, $thumb_width, $thumb_height );
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to get the attachment ID from the attachment URL.
|
||||
*
|
||||
* @since 2.1
|
||||
*
|
||||
* @param string $attachment_url Attachment URL.
|
||||
* @return int Attachment ID
|
||||
*/
|
||||
function tptn_get_attachment_id_from_url( $attachment_url = '' ) {
|
||||
|
||||
global $wpdb;
|
||||
$attachment_id = false;
|
||||
|
||||
// If there is no url, return.
|
||||
if ( '' == $attachment_url ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the upload directory paths.
|
||||
$upload_dir_paths = wp_upload_dir();
|
||||
|
||||
// Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image.
|
||||
if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) {
|
||||
|
||||
// If this is the URL of an auto-generated thumbnail, get the URL of the original image.
|
||||
$attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url );
|
||||
|
||||
// Remove the upload path base directory from the attachment URL.
|
||||
$attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
|
||||
|
||||
// Finally, run a custom database query to get the attachment ID from the modified attachment URL.
|
||||
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = %s AND wposts.post_type = 'attachment'", $attachment_url ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the attachment ID from the attachment URL.
|
||||
*
|
||||
* @since 2.1
|
||||
*
|
||||
* @param int Attachment ID
|
||||
* @param string $attachment_url Attachment URL
|
||||
*/
|
||||
return apply_filters( 'tptn_get_attachment_id_from_url', $attachment_id, $attachment_url );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to get the correct height and width of the thumbnail.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @return array Width and height
|
||||
*/
|
||||
function tptn_get_thumb_size( $args ) {
|
||||
|
||||
// Get thumbnail size.
|
||||
$tptn_thumb_size = tptn_get_all_image_sizes( $args['thumb_size'] );
|
||||
|
||||
if ( isset( $tptn_thumb_size['width'] ) ) {
|
||||
$thumb_width = $tptn_thumb_size['width'];
|
||||
$thumb_height = $tptn_thumb_size['height'];
|
||||
}
|
||||
|
||||
if ( empty( $thumb_width ) || ( $args['is_widget'] && $thumb_width != $args['thumb_width'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$thumb_width = $args['thumb_width'];
|
||||
$args['thumb_html'] = 'css';
|
||||
}
|
||||
|
||||
if ( empty( $thumb_height ) || ( $args['is_widget'] && $thumb_height != $args['thumb_height'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
$thumb_height = $args['thumb_height'];
|
||||
$args['thumb_html'] = 'css';
|
||||
}
|
||||
|
||||
$thumb_size = array( $thumb_width, $thumb_height );
|
||||
|
||||
/**
|
||||
* Filter array of thumbnail size.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $thumb_size Array with width and height of thumbnail
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_get_thumb_size', $thumb_size, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all image sizes.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param string $size Get specific image size.
|
||||
* @return array Image size names along with width, height and crop setting
|
||||
*/
|
||||
function tptn_get_all_image_sizes( $size = '' ) {
|
||||
global $_wp_additional_image_sizes;
|
||||
|
||||
/* Get the intermediate image sizes and add the full size to the array. */
|
||||
$intermediate_image_sizes = get_intermediate_image_sizes();
|
||||
|
||||
foreach ( $intermediate_image_sizes as $_size ) {
|
||||
if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
|
||||
$sizes[ $_size ]['name'] = $_size;
|
||||
$sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
|
||||
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
|
||||
$sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
|
||||
|
||||
if ( ( 0 == $sizes[ $_size ]['width'] ) && ( 0 == $sizes[ $_size ]['height'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
unset( $sizes[ $_size ] );
|
||||
}
|
||||
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
|
||||
|
||||
$sizes[ $_size ] = array(
|
||||
'name' => $_size,
|
||||
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
|
||||
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
|
||||
'crop' => (bool) $_wp_additional_image_sizes[ $_size ]['crop'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get only 1 size if found */
|
||||
if ( $size ) {
|
||||
if ( isset( $sizes[ $size ] ) ) {
|
||||
return $sizes[ $size ];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters array of image sizes.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param array $sizes Image sizes
|
||||
*/
|
||||
return apply_filters( 'tptn_get_all_image_sizes', $sizes );
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,378 @@
|
||||
<?php
|
||||
/**
|
||||
* Generates the output
|
||||
*
|
||||
* @package Top_Ten
|
||||
* @author Ajay D'Souza <me@ajaydsouza.com>
|
||||
* @license GPL-2.0+
|
||||
* @link https://webberzone.com
|
||||
* @copyright 2009-2015 Ajay D'Souza
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the link attributes.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Result object.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_link_attributes( $args, $result ) {
|
||||
|
||||
$rel_attribute = ( $args['link_nofollow'] ) ? ' rel="nofollow" ' : ' ';
|
||||
|
||||
$target_attribute = ( $args['link_new_window'] ) ? ' target="_blank" ' : ' ';
|
||||
|
||||
$link_attributes = array(
|
||||
'rel_attribute' => $rel_attribute,
|
||||
'target_attribute' => $target_attribute,
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter the title of the popular posts list
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $link_attributes Array of link attributes
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
$link_attributes = apply_filters( 'tptn_link_attributes', $link_attributes, $args, $result );
|
||||
|
||||
// Convert it to a string.
|
||||
$link_attributes = implode( ' ', $link_attributes );
|
||||
|
||||
return $link_attributes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the heading of the popular posts.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_heading_title( $args ) {
|
||||
|
||||
$title = '';
|
||||
|
||||
if ( $args['heading'] && ! $args['is_widget'] ) {
|
||||
$title = $args['daily'] ? $args['title_daily'] : $args['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the title of the Top posts.
|
||||
*
|
||||
* @since 1.9.5
|
||||
*
|
||||
* @param string $title Title/heading of the popular posts list
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_heading_title', $title, $args );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the opening tag of the popular posts list.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_before_list( $args ) {
|
||||
|
||||
$before_list = $args['before_list'];
|
||||
|
||||
/**
|
||||
* Filter the opening tag of the popular posts list
|
||||
*
|
||||
* @since 1.9.10.1
|
||||
*
|
||||
* @param string $before_list Opening tag set in the Settings Page
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_before_list', $before_list, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the closing tag of the popular posts list.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_after_list( $args ) {
|
||||
|
||||
$after_list = $args['after_list'];
|
||||
|
||||
/**
|
||||
* Filter the closing tag of the popular posts list
|
||||
*
|
||||
* @since 1.9.10.1
|
||||
*
|
||||
* @param string $after_list Closing tag set in the Settings Page
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_after_list', $after_list, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the opening tag of each list item.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_before_list_item( $args, $result ) {
|
||||
|
||||
$before_list_item = $args['before_list_item'];
|
||||
|
||||
/**
|
||||
* Filter the opening tag of each list item.
|
||||
*
|
||||
* @since 1.9.10.1
|
||||
*
|
||||
* @param string $before_list_item Tag before each list item. Can be defined in the Settings page.
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_before_list_item', $before_list_item, $result, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the closing tag of each list item.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_after_list_item( $args, $result ) {
|
||||
|
||||
$after_list_item = $args['after_list_item'];
|
||||
|
||||
/**
|
||||
* Filter the closing tag of each list item.
|
||||
*
|
||||
* @since 1.9.10.1
|
||||
*
|
||||
* @param string $after_list_item Tag after each list item. Can be defined in the Settings page.
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_after_list_item', $after_list_item, $result, $args ); // Pass the post object to the filter.
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the title of each list item.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_post_title( $args, $result ) {
|
||||
|
||||
$title = tptn_trim_char( get_the_title( $result->ID ), $args['title_length'] ); // Get the post title and crop it if needed.
|
||||
|
||||
/**
|
||||
* Filter the post title of each list item.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $title Title of the post.
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_post_title', $title, $result, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the author of each list item.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_author( $args, $result ) {
|
||||
|
||||
$author_info = get_userdata( $result->post_author );
|
||||
$author_link = ( false === $author_info ) ? '' : get_author_posts_url( $author_info->ID );
|
||||
$author_name = ( false === $author_info ) ? '' : ucwords( trim( stripslashes( $author_info->display_name ) ) );
|
||||
|
||||
/**
|
||||
* Filter the author name.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*
|
||||
* @param string $author_name Proper name of the post author.
|
||||
* @param object $author_info WP_User object of the post author
|
||||
*/
|
||||
$author_name = apply_filters( 'tptn_author_name', $author_name, $author_info );
|
||||
|
||||
if ( ! empty( $author_name ) ) {
|
||||
$tptn_author = '<span class="crp_author"> ' . __( ' by ', 'top-10' ) . '<a href="' . $author_link . '">' . $author_name . '</a></span> ';
|
||||
} else {
|
||||
$tptn_author = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the text with the author details.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $tptn_author Formatted string with author details and link
|
||||
* @param object $author_info WP_User object of the post author
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_author', $tptn_author, $author_info, $result, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the formatted list item with link and and thumbnail for each list item.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @return string Space separated list of link attributes
|
||||
*/
|
||||
function tptn_list_link( $args, $result ) {
|
||||
|
||||
$output = '';
|
||||
$title = tptn_post_title( $args, $result );
|
||||
$link_attributes = tptn_link_attributes( $args, $result );
|
||||
|
||||
if ( 'after' === $args['post_thumb_op'] ) {
|
||||
$output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link.
|
||||
$output .= '<span class="tptn_title">' . $title . '</span>'; // Add title if post thumbnail is to be displayed after.
|
||||
$output .= '</a>'; // Close the link.
|
||||
}
|
||||
|
||||
if ( 'inline' === $args['post_thumb_op'] || 'after' === $args['post_thumb_op'] || 'thumbs_only' === $args['post_thumb_op'] ) {
|
||||
$output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link.
|
||||
|
||||
$output .= tptn_get_the_post_thumbnail(
|
||||
array(
|
||||
'postid' => $result,
|
||||
'thumb_height' => $args['thumb_height'],
|
||||
'thumb_width' => $args['thumb_width'],
|
||||
'thumb_meta' => $args['thumb_meta'],
|
||||
'thumb_html' => $args['thumb_html'],
|
||||
'thumb_default' => $args['thumb_default'],
|
||||
'thumb_default_show' => $args['thumb_default_show'],
|
||||
'scan_images' => $args['scan_images'],
|
||||
'class' => 'tptn_thumb',
|
||||
)
|
||||
);
|
||||
|
||||
$output .= '</a>'; // Close the link.
|
||||
}
|
||||
|
||||
if ( 'inline' === $args['post_thumb_op'] || 'text_only' === $args['post_thumb_op'] ) {
|
||||
$output .= '<span class="tptn_after_thumb">';
|
||||
$output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $link_attributes . ' class="tptn_link">'; // Add beginning of link.
|
||||
$output .= '<span class="tptn_title">' . $title . '</span>'; // Add title when required by settings.
|
||||
$output .= '</a>'; // Close the link.
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Formatted list item with link and and thumbnail.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $output Formatted list item with link and and thumbnail
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_list_link', $output, $result, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the title of each list item.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @return string Formatted post date
|
||||
*/
|
||||
function tptn_date( $args, $result ) {
|
||||
|
||||
$date = mysql2date( get_option( 'date_format', 'd/m/y' ), $result->post_date );
|
||||
|
||||
/**
|
||||
* Filter the post title of each list item.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $date Title of the post.
|
||||
* @param object $result Object of the current post result
|
||||
* @param array $args Array of arguments
|
||||
*/
|
||||
return apply_filters( 'tptn_date', $date, $result, $args );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the title of each list item.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param array $args Array of arguments.
|
||||
* @param object $result Object of the current post result.
|
||||
* @param int $visits Number of visits.
|
||||
* @return string Formatted post date
|
||||
*/
|
||||
function tptn_list_count( $args, $result, $visits ) {
|
||||
|
||||
$tptn_list_count = '(' . tptn_number_format_i18n( $visits ) . ')';
|
||||
|
||||
/**
|
||||
* Filter the formatted list count text.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $visits Formatted list count
|
||||
* @param int $visits Post count
|
||||
* @param object $result Post object
|
||||
* @param array $args Array of arguments.
|
||||
* @param int $visits Number of visits.
|
||||
*/
|
||||
return apply_filters( 'tptn_list_count', $tptn_list_count, $visits, $result, $args, $visits );
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions dealing with styles.
|
||||
*
|
||||
* @package Top_Ten
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to add CSS to header.
|
||||
*
|
||||
* @since 1.9
|
||||
*/
|
||||
function tptn_header() {
|
||||
|
||||
$tptn_custom_css = stripslashes( tptn_get_option( 'custom_css' ) );
|
||||
|
||||
// Add CSS to header.
|
||||
if ( '' != $tptn_custom_css ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
|
||||
echo '<style type="text/css">' . $tptn_custom_css . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
add_action( 'wp_head', 'tptn_header' );
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue styles.
|
||||
*/
|
||||
function tptn_heading_styles() {
|
||||
|
||||
$style_array = tptn_get_style();
|
||||
|
||||
if ( ! empty( $style_array['name'] ) ) {
|
||||
$style = $style_array['name'];
|
||||
$extra_css = $style_array['extra_css'];
|
||||
|
||||
wp_register_style( "tptn-style-{$style}", plugins_url( "css/{$style}.min.css", TOP_TEN_PLUGIN_FILE ), array(), '1.0.1' );
|
||||
wp_enqueue_style( "tptn-style-{$style}" );
|
||||
wp_add_inline_style( "tptn-style-{$style}", $extra_css );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'tptn_heading_styles' );
|
||||
|
||||
|
||||
/**
|
||||
* Get the current style for the popular posts.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array Contains two elements:
|
||||
* 'name' holding style name and 'extra_css' to be added inline.
|
||||
*/
|
||||
function tptn_get_style() {
|
||||
|
||||
$style = array();
|
||||
$thumb_width = tptn_get_option( 'thumb_width' );
|
||||
$thumb_height = tptn_get_option( 'thumb_height' );
|
||||
$tptn_style = tptn_get_option( 'tptn_styles' );
|
||||
|
||||
switch ( $tptn_style ) {
|
||||
case 'left_thumbs':
|
||||
$style['name'] = 'left-thumbs';
|
||||
$style['extra_css'] = "
|
||||
.tptn_related a {
|
||||
width: {$thumb_width}px;
|
||||
height: {$thumb_height}px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.tptn_related img {
|
||||
max-width: {$thumb_width}px;
|
||||
margin: auto;
|
||||
}
|
||||
.tptn_related .tptn_title {
|
||||
width: 100%;
|
||||
}
|
||||
";
|
||||
break;
|
||||
|
||||
default:
|
||||
$style['name'] = '';
|
||||
$style['extra_css'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $style;
|
||||
}
|
Reference in New Issue
Block a user