php 最近的全球事件短代码。需要“Post Indexer”和Events +插件。提供短代码:`[global_recent_events]`allong with severa

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 最近的全球事件短代码。需要“Post Indexer”和Events +插件。提供短代码:`[global_recent_events]`allong with severa相关的知识,希望对你有一定的参考价值。

<?php
/**
 * Plugin Name: Recent Global Events
 * Plugin URI: http://premium.wpmudev.org
 * Description: Recent Global Evens function and shortcode. Requires "Post Indexer" and Events+ plugins. Provides shortcode: `[global_recent_events]` allong with several atts
 * Author: Panos Lyrakis @ WPMUDEV
 * Author URI:  http://premium.wpmudev.org
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/

if( ! class_exists( 'WPMUDEV_Recent_Global_Events' ) ){

class WPMUDEV_Recent_Global_Events {

	var $build = 1;

	var $db;

	private static $_instance = null;
        
	public static function get_instance() {
		if( is_null( self::$_instance ) ){
			self::$_instance = new WPMUDEV_Recent_Global_Events();
		}
        return self::$_instance;
        
	}

	private function __construct() {

		global $wpdb;

		if( ! class_exists('Eab_EventsHub') ){
			return;
		}

		$this->db =& $wpdb;

		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_events_front_style' ), 999 );

		add_shortcode( 'global_recent_events', array( &$this, 'display_recent_posts_shortcode') );

	}

	public function enqueue_events_front_style(){

		global $post;
		if ( has_shortcode( $post->post_content, 'global_recent_events' ) ){

			wp_enqueue_style('eab_front');
		}

	}

	public function display_recent_posts($tmp_number,$tmp_title_characters = 0,$tmp_content_characters = 0,$tmp_title_content_divider = '<br />',$tmp_title_before,$tmp_title_after,$tmp_global_before,$tmp_global_after,$tmp_before,$tmp_after,$tmp_title_link = 'no',$tmp_show_avatars = 'yes', $tmp_avatar_size = 16, $posttype = 'post', $output = true) {

		global $network_query, $network_post;

		$network_query = network_query_posts( array( 'post_type' => $posttype, 'posts_per_page' => $tmp_number ));

		$html = '';

		if( network_have_posts() ) {
			$html .= $tmp_global_before;
			$default_avatar = get_option('default_avatar');

			while( network_have_posts()) {
				network_the_post();

				$html .= $tmp_before;
				if ( $tmp_title_characters > 0 ) {
					$html .= $tmp_title_before;
					if ( $tmp_show_avatars == 'yes' ) {
						$the_author = network_get_the_author_id();
						$html .= get_avatar( $the_author, $tmp_avatar_size, $default_avatar) . ' ';
					}
					$the_title = network_get_the_title();
					if ( $tmp_title_link == 'no' ) {
						$html .= substr($the_title,0,$tmp_title_characters);
					} 
					else {

						if( $posttype != 'incsub_event' && class_exists( 'Eab_Template' ) ){
							$html .= '<a href="' . network_get_permalink() . '" >' . substr($the_title,0,$tmp_title_characters) . '</a>';
						}
						else{
							ob_start();

							$event = &network_get_post();
							switch_to_blog( $event->BLOG_ID );
							?>

							 <div class="event <?php echo Eab_Template::get_status_class($event); ?>" style="clear:both; margin-bottom: 80px;">
	                            <div class="wpmudevevents-header entry-header">
	                                <h3><?php echo Eab_Template::get_event_link($event); ?></h3>	                                
	                            </div>

	                            <div style="clear:both;">
	                            <a href="<?php echo network_get_permalink(); ?>" class="wpmudevevents-viewevent"><?php _e('View event', Eab_EventsHub::TEXT_DOMAIN); ?></a>
		                            
		                            <?php
		                                echo Eab_Template::get_event_details($event);
		                            ?>
		                            <?php
		                                echo Eab_Template::get_rsvp_form($event);
		                            ?>
	                        	</div>
	                            
	                        </div>
	                        <hr />

							<?php
							restore_current_blog();

							$html .= ob_get_clean();
						}
					}

					$html .= $tmp_title_after;
				}
				$html .= $tmp_title_content_divider;

				if ( $tmp_content_characters > 0 ) {
					$the_content = network_get_the_content();
					$html .= substr(strip_tags($the_content),0,$tmp_content_characters);
				}
				$html .= $tmp_after;

			}
			$html .= $tmp_global_after;
		}

		if($output) {
			echo $html;
		} else {
			return $html;
		}

	}

	function display_recent_posts_shortcode($atts, $content = null, $code = "") {

		$defaults = array(	'number'	=>	5,
							'title_characters' => 250,
							'content_characters' => 0,
							'title_content_divider' => '<br />',
							'title_before'	=>	'',
							'title_after'	=>	'',
							'global_before'	=>	'',//'<ul>',
							'global_after'	=>	'',//'</ul>',
							'before'	=>	'',//'<li>',
							'after'	=>	'',//'</li>',
							'title_link' => 'yes',
							'show_avatars' => 'no',
							'avatar_size' => 16,
							'posttype' => 'incsub_event'
						);

		extract(shortcode_atts($defaults, $atts));

		$html = '';

		$html .= $this->display_recent_posts( $number, $title_characters, $content_characters, $title_content_divider, $title_before, $title_after, $global_before, $global_after, $before, $after, $title_link, $show_avatars, $avatar_size, $posttype, false);

		return $html;

	}

}

add_action( 'plugins_loaded', function(){
	$GLOBALS['WPMUDEV_Recent_Global_Events'] = WPMUDEV_Recent_Global_Events::get_instance();
}, 10 );

}

以上是关于php 最近的全球事件短代码。需要“Post Indexer”和Events +插件。提供短代码:`[global_recent_events]`allong with severa的主要内容,如果未能解决你的问题,请参考以下文章

加速此代码 - PHP/SQL - 短代码,但目前需要非常长的时间

php 覆盖事件列表小部件的/短代码的“查看更多...”链接(也可能影响其他地方)* *对于https://theeventscalendar.com/suppor

php 覆盖事件列表小部件的/短代码的“查看更多...”链接(也可能影响其他地方)* *对于https://theeventscalendar.com/suppor

php 事件日历PRO:即使对于tribe_events短代码,也使tribe_is_week()返回TRUE。

php 事件日历PRO:即使对于tribe_events短代码,也使tribe_is_week()返回TRUE。

php 事件日历PRO:将{pro_addl_fields}变量添加到tribe_event_inline短代码中。