false, 'instance_id' => 1, 'is_widget' => false, 'is_shortcode' => false, 'is_manual' => false, 'is_block' => false, 'echo' => false, 'strict_limit' => false, 'heading' => 1, 'offset' => 0, 'extra_class' => '', ); // 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 ); // Sanitize the attributes. $args = Helpers::sanitize_args( $args ); // Short circuit flag. $short_circuit = false; /** * Allow a short circuit flag to be set to exit at this stage. Set to true to exit. * * @since 4.0.0 * * @param bool $short_circuit Short circuit filter. * @param array $args Arguments array. * @param \WP_Post $post Current Post object. */ $short_circuit = apply_filters( 'get_tptn_short_circuit', $short_circuit, $args, $post ); if ( $short_circuit ) { return ''; // Exit without adding popular posts. } $output = ''; /** * Fires before the output processing begins. * * @since 3.1.0 * * @param string $output Formatted list of top posts. * @param array $args Array of arguments. * @param \WP_Post $post Current Post object. */ do_action( 'pre_tptn_pop_posts', $output, $args, $post ); // Check exclusions. if ( self::exclude_on( $post, $args ) ) { return ''; } /** * Pre-filter the popular posts output. * * Return a non-null value to short-circuit the default rendering, e.g. to * replace it with a lazy load placeholder. Runs for all display methods. * * @since 4.4.0 * * @param string|null $pre Pre-rendered output. Default null. * @param array $args Fully parsed arguments array. * @param \WP_Post|null $post Current post object. */ $pre = apply_filters( 'tptn_pre_pop_posts', null, $args, $post ); if ( null !== $pre ) { return (string) $pre; } // Check if the cache is enabled and if the output exists. If so, return the output. if ( $args['cache'] ) { $cache_name = \WebberZone\Top_Ten\Util\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'] ) = Media_Handler::get_thumb_size( $args['thumb_size'] ); // Retrieve the popular posts. $results = self::get_posts( $args ); $counter = 0; // Override tptn_styles if post_thumb_op is text_only. $args['tptn_styles'] = ( 'text_only' === $args['post_thumb_op'] ) ? 'text_only' : $args['tptn_styles']; $style_array = Styles_Handler::get_style( $args['tptn_styles'] ); $post_classes = array( 'main' => $args['daily'] ? 'tptn_posts_daily ' : 'tptn_posts ', 'widget' => $args['is_widget'] ? 'tptn_posts_widget tptn_posts_widget-' . $args['instance_id'] : '', 'shortcode' => $args['is_shortcode'] ? 'tptn_posts_shortcode' : '', 'block' => $args['is_block'] ? 'tptn_posts_block' : '', 'extra_class' => $args['extra_class'], 'style' => ! empty( $style_array['name'] ) ? str_replace( '-pro', '', 'tptn-' . $style_array['name'] ) : '', ); $post_classes = join( ' ', $post_classes ); /** * 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 .= '