Example #1
0
    function widget($args = [], $instance = [])
    {
        $instance = array_merge(['title' => ___('User point rank'), 'total_number' => 100, 'rand_number' => 12], $instance);
        if ((int) $instance['total_number'] === 0 || (int) $instance['rand_number'] === 0) {
            return false;
        }
        echo $args['before_widget'];
        echo $args['before_title'];
        ?>
		<i class="fa fa-bar-chart"></i> <?php 
        echo $instance['title'];
        ?>
		<?php 
        echo $args['after_title'];
        $query = new WP_User_Query(['meta_key' => theme_custom_point::$user_meta_key['point'], 'orderby' => 'meta_value_num', 'order' => 'desc', 'number' => (int) $instance['total_number'], 'fields' => 'ID']);
        $users = $query->get_results();
        $count = count($users);
        if ($count < 2) {
            ?>
			<div class="content">
				<div class="page-tip"><?php 
            echo status_tip('info', ___('No matched user yet.'));
            ?>
</div>
			</div>
			<?php 
        } else {
            /**
             * rand
             */
            if ($instance['rand_number'] > $count) {
                $instance['rand_number'] = $count;
            }
            $rand_users = (array) array_rand($users, $instance['rand_number']);
            ?>
			<div class="content">
				<div class="user-lists row">
					<?php 
            $user = null;
            foreach ($rand_users as $k) {
                theme_functions::the_user_list(['user_id' => $users[$k], 'extra' => 'point', 'extra_title' => sprintf(__x('%s %s', 'eg. 20 points'), '%', theme_custom_point::get_point_name())]);
            }
            ?>
				</div>
			</div>
			<?php 
        }
        unset($query, $users, $rand_users);
        echo $args['after_widget'];
    }
Example #2
0
 /**
  * Test basic context support using mo files.
  *
  * @return void
  */
 public function testContextMoFile()
 {
     Configure::write('Config.language', 'nld_mo');
     $this->assertSame("brief", __x('mail', 'letter'));
     $this->assertSame("letter", __x('character', 'letter'));
     $this->assertSame("bal", __x('spherical object', 'ball'));
     $this->assertSame("danspartij", __x('social gathering', 'ball'));
     $this->assertSame("balans", __('balance'));
     $this->assertSame("saldo", __x('money', 'balance'));
 }
Example #3
0
    public static function post_btn($post_id)
    {
        $point_img = theme_custom_point::get_point_img_url();
        $point_values = array_filter((array) self::get_point_values());
        $count_point_values = count($point_values);
        $default_point_value = $point_values[0];
        if ($count_point_values > 1) {
            sort($point_values);
        }
        ?>
		<div class="meta meta-post-point">
			<a 
				href="javascript:;" 
				class="post-point-btn" 
				title="<?php 
        echo sprintf(__x('Rate %d %s.', 'E.g. Rate 3 points'), $default_point_value, theme_custom_point::get_point_name());
        ?>
" 
				data-post-id="<?php 
        echo $post_id;
        ?>
" 
				data-points="<?php 
        echo $default_point_value;
        ?>
" 
			>
				<div id="post-point-number-<?php 
        echo $post_id;
        ?>
" class="number"><?php 
        echo number_format((int) self::get_post_points_count($post_id));
        ?>
</div>
				<div class="tx"><?php 
        echo ___('Rate it');
        ?>
</div>
			</a>
			<?php 
        if (!wp_is_mobile() && $count_point_values > 1) {
            ?>
				<div class="box">
					<?php 
            foreach ($point_values as $v) {
                $class = $v == $default_point_value ? 'active' : null;
                ?>
<a 
							href="javascript:;" 
							class="post-point-btn <?php 
                echo $class;
                ?>
" 
							title="<?php 
                echo sprintf(__x('Rate %d %s.', 'E.g. Rate 3 points'), $v, theme_custom_point::get_point_name());
                ?>
" 
							data-post-id="<?php 
                echo $post_id;
                ?>
" 
							data-points="<?php 
                echo $v;
                ?>
" 
						><?php 
                echo $v;
                ?>
</a><?php 
            }
            ?>
				</div>
			<?php 
        }
        ?>
		</div>
		<?php 
    }
Example #4
0
 /**
  * Test basic context support using mo files.
  *
  * @return void
  */
 public function testContextMoFile()
 {
     Configure::write('Config.language', 'nld_mo');
     $this->assertSame("brief", __x('mail', 'letter'));
     $this->assertSame("letter", __x('character', 'letter'));
     $this->assertSame("bal", __x('spherical object', 'ball'));
     $this->assertSame("danspartij", __x('social gathering', 'ball'));
     $this->assertSame("balans", __('balance'));
     $this->assertSame("saldo", __x('money', 'balance'));
     // MO file is sorted by msgid, 'zoo' should be last
     $this->assertSame("dierentuin", __('zoo'));
 }
Example #5
0
 /**
  * Tests the __x() function
  *
  * @return void
  */
 public function testBasicContextFunction()
 {
     I18n::translator('default', 'en_US', function () {
         $package = new Package('default');
         $package->setMessages(['letter' => ['_context' => ['character' => 'The letter {0}', 'communication' => 'She wrote a letter to {0}']]]);
         return $package;
     });
     $this->assertEquals('The letter A', __x('character', 'letter', ['A']));
     $this->assertEquals('She wrote a letter to Thomas', __x('communication', 'letter', ['Thomas']));
 }
Example #6
0
    /** 
     * singular_content
     */
    public static function singular_content(array $args = [])
    {
        global $post;
        $args = array_merge(array('classes' => '', 'lazyload' => true), $args);
        /** 
         * classes
         */
        $args['classes'] .= ' singular-post panel ';
        $author_display_name = theme_cache::get_the_author_meta('display_name', $post->post_author);
        $author_url = theme_cache::get_author_posts_url($post->post_author);
        ?>
		<article id="post-<?php 
        echo $post->ID;
        ?>
" <?php 
        post_class($args['classes']);
        ?>
>
			<h2 class="entry-title"><?php 
        echo theme_cache::get_the_title($post->ID);
        ?>
</h2>
			<header class="entry-header">
				<!-- category -->
				<?php 
        $cats = get_the_category_list('<i class="split"> / </i> ');
        if (!empty($cats)) {
            ?>
					<span class="entry-meta post-category" title="<?php 
            echo ___('Category');
            ?>
">
						<i class="fa fa-folder-open"></i>
						<?php 
            echo $cats;
            ?>
					</span>
				<?php 
        }
        ?>
				
				<!-- time -->
				<time class="entry-meta post-time" datetime="<?php 
        echo get_the_time('Y-m-d H:i:s');
        ?>
" title="<?php 
        echo get_the_time(___('M j, Y'));
        ?>
">
					<i class="fa fa-clock-o"></i>
					<?php 
        echo friendly_date(get_the_time('U'));
        ?>
				</time>
				<!-- author link -->
				<a class="entry-meta post-author" href="<?php 
        echo $author_url;
        ?>
" title="<?php 
        echo sprintf(___('Views all post by %s'), $author_display_name);
        ?>
">
					<i class="fa fa-user"></i> 
					<?php 
        echo $author_display_name;
        ?>
				</a>
				
				<!-- views -->
				<?php 
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            ?>
					<span class="entry-meta post-views" title="<?php 
            echo ___('Views');
            ?>
">
						<i class="fa fa-play-circle"></i>
						<span class="number" id="post-views-number-<?php 
            echo $post->ID;
            ?>
">-</span>
					</span>
				<?php 
        }
        ?>
				<?php 
        /** 
         * comment
         */
        $comment_count = (int) get_comments_number() . '';
        ?>
				<a href="#comments" class="entry-meta quick-comment comment-count" data-post-id="<?php 
        echo $post->ID;
        ?>
">
					<i class="fa fa-comment"></i>
					<span class="comment-count-number"><?php 
        echo $comment_count;
        ?>
</span>
				</a>
				<?php 
        /**
         * edit
         */
        if (class_exists('theme_custom_edit') && $post->post_author == theme_cache::get_current_user_id()) {
            ?>
					<a class="post-meta edit-post" href="<?php 
            echo theme_custom_edit::get_edit_post_link($post->ID);
            ?>
">
						<i class="fa fa-edit"></i> <?php 
            echo ___('Edit');
            ?>
					</a>
				<?php 
        }
        ?>
				
				
			</header>
			<div class="entry-body">
				<?php 
        /**
         * ad
         */
        if (class_exists('theme_adbox') && !empty(theme_adbox::display_frontend('below-post-title'))) {
            ?>
					<div class="ad-container ad-below-post-title"><?php 
            echo theme_adbox::display_frontend('below-post-title');
            ?>
</div>
					<?php 
        }
        ?>
				<!-- entry-excerpt -->
				<?php 
        $excerpt = $post->post_excerpt;
        if ($excerpt !== '') {
            ?>
					<blockquote class="entry-excerpt">
						<?php 
            echo $excerpt;
            ?>
					</blockquote>
				<?php 
        }
        ?>
				<!-- post-content -->
				<div class="entry-content content-reset">
					<?php 
        the_content();
        ?>
				</div>

				<?php 
        self::the_page_pagination();
        ?>

				<!-- entry-circle -->
				<div class="entry-circle">
					<?php 
        /** post points */
        if (class_exists('custom_post_point') && class_exists('theme_custom_point')) {
            custom_post_point::post_btn($post->ID);
        }
        /** theme_custom_storage */
        if (class_exists('theme_custom_storage') && theme_custom_storage::is_enabled()) {
            theme_custom_storage::display_frontend($post->ID);
        }
        ?>
					<a class="meta meta-post-comments" href="<?php 
        echo $post->comment_count == 0 ? '#respond' : '#comments';
        ?>
" id="post-comments-btn" title="<?php 
        echo ___('Comments');
        ?>
">
						<div id="post-comments-number-<?php 
        echo $post_id;
        ?>
" class="number">
							<?php 
        echo (int) $post->comment_count;
        ?>
						</div>
						<div class="tx"><?php 
        echo __x('Comments', 'Tucao');
        ?>
</div>
					</a>
				</div>
				
				<!-- theme_custom_post_source -->
				<?php 
        if (class_exists('theme_custom_post_source') && theme_custom_post_source::is_enabled()) {
            ?>
					<ul class="entry-source">
						<?php 
            theme_custom_post_source::display_frontend($post->ID);
            ?>
					</ul>
					<?php 
        }
        ?>
					
				<!-- post-footer -->
				<footer class="entry-footer">
					<?php 
        /** 
         * tags
         */
        $tags = get_the_tags();
        if (!empty($tags)) {
            ?>
						<div class="entry-tags">
							<?php 
            the_tags('', '');
            ?>
						</div>
						<?php 
        }
        ?>
					<?php 
        /** 
         * post-share
         */
        if (class_exists('theme_post_share') && theme_post_share::is_enabled()) {
            ?>
						<div class="entry-share">
							<?php 
            echo theme_post_share::display();
            ?>
						</div>
						<?php 
        }
        /** end post-share */
        ?>

					<?php 
        /**
         * report
         */
        if (class_exists('theme_custom_report') && theme_custom_report::is_enabled()) {
            ?>
						<div class="entry-report">
							<?php 
            echo theme_custom_report::display_frontend();
            ?>
						</div>
						<?php 
        }
        ?>
				</footer>
			</div><!-- /.entry-body -->
			
		</article>
		<?php 
    }
Example #7
0
    function widget($args, $instance)
    {
        global $post;
        $author_id = $post->post_author;
        echo $args['before_widget'];
        /**
         * author profile page url
         */
        if (class_exists('theme_custom_author_profile')) {
            $author_url = theme_custom_author_profile::get_tabs('profile', $author_id)['url'];
        } else {
            $author_url = theme_cache::get_author_posts_url($author_id);
        }
        $description = theme_cache::get_the_author_meta('description', $author_id);
        ?>
	
		<div id="widget-author-card" class="widget-container content">
			<a href="<?php 
        echo $author_url;
        ?>
" class="author-link" title="<?php 
        echo ___('Views the author information detail');
        ?>
">
				<?php 
        echo theme_cache::get_avatar($author_id, 100);
        ?>
				
				<h3 class="author-card-name">
					<?php 
        echo theme_cache::get_the_author_meta('display_name', $author_id);
        ?>
				</h3>
				
				<?php 
        if (class_exists('theme_custom_author_profile')) {
            ?>
					<small class="label label-<?php 
            echo theme_custom_author_profile::get_roles($author_id)['label'];
            ?>
"><?php 
            echo theme_custom_author_profile::get_roles($author_id)['name'];
            ?>
</small>
				<?php 
        }
        ?>
			</a><!-- ./author-link -->
			
			<p class="author-card-description" title="<?php 
        echo $description;
        ?>
" >
				<?php 
        if (empty($description)) {
            echo ___('The author is lazy, nothing writes here.');
        } else {
            echo $description;
        }
        ?>
			</p>
			
			<?php 
        if (class_exists('theme_custom_author_profile')) {
            ?>
				<div class="author-card-meta-links">
					<!-- works count -->
					<a class="tooltip" href="<?php 
            echo theme_custom_author_profile::get_tabs('works', $author_id)['url'];
            ?>
" title="<?php 
            echo ___('Views author posts');
            ?>
" target="_blank">
						<span class="tx"><i class="fa fa-fw fa-<?php 
            echo theme_custom_author_profile::get_tabs('works', $author_id)['icon'];
            ?>
"></i></span>
						<span class="count"><?php 
            echo (int) theme_custom_author_profile::get_tabs('works', $author_id)['count'];
            ?>
</span>
					</a>
					<!-- comments count -->
					<a class="tooltip" href="<?php 
            echo theme_custom_author_profile::get_tabs('comments', $author_id)['url'];
            ?>
" title="<?php 
            echo ___('Views author comments');
            ?>
" target="_blank">
						<span class="tx"><i class="fa fa-fw fa-<?php 
            echo theme_custom_author_profile::get_tabs('comments', $author_id)['icon'];
            ?>
"></i></span>
						<span class="count"><?php 
            echo (int) theme_custom_author_profile::get_tabs('comments', $author_id)['count'];
            ?>
</span>
					</a>
					<!-- point -->
					<?php 
            if (class_exists('theme_custom_point_bomb')) {
                if (class_exists('number_user_nicename')) {
                    $target_id = number_user_nicename::$prefix_number + $author_id;
                } else {
                    $target_id = $author_id;
                }
                ?>
						<!-- followers count -->
						<a class="tooltip" href="<?php 
                echo theme_custom_point_bomb::get_tabs('bomb', $target_id)['url'];
                ?>
" rel="nofollow" title="<?php 
                echo ___('Bomb!');
                ?>
" target="_blank">
							<span class="tx"><i class="fa fa-fw fa-bomb"></i></span>
							<span class="count"><?php 
                echo theme_custom_point::get_point($author_id);
                ?>
</span>
						</a>
					<?php 
            }
            ?>
					
					<!-- pm -->
					<?php 
            if (class_exists('theme_custom_pm')) {
                ?>
						<a target="_blank" class="tooltip" href="<?php 
                echo theme_custom_pm::get_user_pm_url($author_id);
                ?>
" title="<?php 
                echo ___('Send a private message.');
                ?>
">
							<span class="tx"><i class="fa fa-<?php 
                echo theme_custom_pm::get_tabs('pm')['icon'];
                ?>
"></i></span><span class="count"><?php 
                echo __x('P.M.', 'Widget author card PM.');
                ?>
</span>
						</a>
					<?php 
            }
            ?>
				</div>
			<?php 
        }
        ?>
		</div>
		<?php 
        echo $args['after_widget'];
    }
<?php

__('Translations extraction test');
tr('Translations extraction test');
__n('Singular', 'Plurals', 2);
__x('With a context', 'Singular');
__xn('With a context', 'Singular', 'Plurals', 2);
Example #9
0
    /**
     * Renders the Network-Wide Protection help contents
     *
     * @since  1.0.0
     * @return string
     */
    public function render_tab_network()
    {
        ob_start();
        ?>
		<h2><?php 
        _ex('Network-Wide Protection', 'help', MS_TEXT_DOMAIN);
        ?>
</h2>
		<p>
			<?php 
        sprintf(__x('Network wide protection is a Pro feature. %sRead more about the Pro Version here%s!', 'help', MS_TEXT_DOMAIN), '<a href="http://premium.wpmudev.org/project/membership" target="_blank">', '</a>');
        ?>
		</p>
		<hr />
		<?php 
        return ob_get_clean();
    }