public static function init() { add_filter('theme_options_save', __CLASS__ . '::options_save'); add_filter('theme_options_default', __CLASS__ . '::options_default'); add_action('base_settings', __CLASS__ . '::display_backend'); if (theme_functions::$link_target !== self::get_target()) { theme_functions::$link_target = self::get_target(); } }
public static function init() { add_filter('theme_options_save', __CLASS__ . '::options_save'); add_filter('theme_options_default', __CLASS__ . '::options_default'); add_action('base_settings', __CLASS__ . '::display_backend'); if (theme_functions::$thumbnail_placeholder !== self::get_options('thumbnail')) { theme_functions::$thumbnail_placeholder = self::get_options('thumbnail'); } if (theme_functions::$avatar_placeholder !== self::get_options('avatar')) { theme_functions::$avatar_placeholder = self::get_options('avatar'); } }
public static function frontend_display(array $args = [], $instance) { global $post; $instance = array_merge(['title' => ___('Author posts'), 'posts_per_page' => 12, 'orderby' => 'random', 'content_type' => 'img'], $instance); echo $args['before_title']; ?> <a href="<?php echo class_exists('theme_custom_author_profile') ? theme_custom_author_profile::get_tabs('works', $post->post_author)['url'] : theme_cache::get_author_posts_url($post->post_author); ?> " title="<?php echo ___('Views more author posts.'); ?> "> <i class="fa fa-file-text"></i> <?php echo sprintf($instance['title'], theme_cache::get_the_author_meta('display_name', $post->post_author)); ?> </a> <?php echo $args['after_title']; $query = new WP_Query(['posts_per_page' => (int) $instance['posts_per_page'], 'orderby' => $instance['orderby'], 'author' => $post->post_author, 'post_not__in' => [$post->ID], 'ignore_sticky_posts' => true]); ?> <div class="card-container"> <?php if ($query->have_posts()) { ?> <div class="row widget-author-post-<?php echo $instance['orderby']; ?> "> <?php foreach ($query->posts as $post) { setup_postdata($post); theme_functions::archive_card_xs(['classes' => 'g-phone-1-2']); } wp_reset_postdata(); ?> </div> <?php } else { ?> <div class="page-tip not-found"> <?php echo status_tip('info', ___('No data yet.')); ?> </div> <?php } ?> </div> <?php unset($query); }
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']; }
<?php get_header(); ?> <div class="g"> <div class="row"> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <div id="main" class="main g-desktop-3-4"> <?php theme_functions::page_content(); ?> <?php comments_template(); ?> </div> <?php include __DIR__ . '/sidebar.php'; ?> <?php } } else { ?> <?php } ?>
public static function process() { theme_features::check_referer(); theme_features::check_nonce(); $output = []; /** * Check the ajax comment post */ if (isset($_POST['comment_post_ID']) && is_string($_POST['comment_post_ID'])) { $comment_post_ID = (int) $_POST['comment_post_ID']; do_action('pre_comment_on_post', $comment_post_ID); global $wp_query, $comment, $comments, $post, $wpdb; $user = wp_get_current_user(); /** * Define comment values */ $comment_author = isset($_POST['author']) && is_string($_POST['author']) ? trim($_POST['author']) : null; $comment_author_email = isset($_POST['email']) && is_string($_POST['email']) && is_email($_POST['email']) ? trim($_POST['email']) : null; $comment_author_url = isset($_POST['url']) && is_string($_POST['url']) ? trim($_POST['url']) : null; $comment_content = isset($_POST['comment']) && is_string($_POST['comment']) ? trim($_POST['comment']) : null; $comment_parent = isset($_POST['comment_parent']) && is_numeric($_POST['comment_parent']) ? $_POST['comment_parent'] : null; $output['status'] = 'success'; kses_remove_filters(); /** * If logged */ if ($user->exists()) { if (empty($use->nickname)) { if (empty($user->display_name)) { $user->display_name = $user->user_login; } } else { if (empty($user->display_name)) { $user->display_name = $user->display_name; } } $comment_author = wp_slash($user->display_name); $comment_author_email = wp_slash($user->user_email); $comment_author_url = wp_slash($user->user_url); $user_id = $user->ID; //if(theme_cache::current_user_can('unfiltered_html')){ // if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) // || ! wp_verify_nonce( $_POST['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID ) // ) { //kses_remove_filters(); // start with a clean slate //kses_init_filters(); // set up the filters // } //} /** * If not login, just visitor */ } else { if ((int) theme_cache::get_option('comment_registration') === 1) { $output['status'] = 'error'; $output['msg'] = ___('Sorry, you must be logged in to post a comment.'); die(theme_features::json_format($output)); } } /** * Check required */ if (theme_cache::get_option('require_name_email') && !$user->exists()) { if (empty($comment_author)) { $output['status'] = 'error'; $output['code'] = 'invaild_name'; $output['msg'] = ___('Error: please fill your name.'); die(theme_features::json_format($output)); } else { if (!$comment_author_email) { $output['status'] = 'error'; $output['code'] = 'invaild_email'; $output['msg'] = ___('Error: please enter a valid email address.'); die(theme_features::json_format($output)); } } } /** * If no comment content */ if (empty($comment_content)) { $output['status'] = 'error'; $output['code'] = 'invaild_content'; $output['msg'] = ___('Error: please type a comment.'); die(theme_features::json_format($output)); } /** * Compact the information */ $comment_type = null; $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_id'); /** * Insert new comment and get the comment ID */ $comment_id = wp_new_comment($commentdata); /** * Get new comment and set cookie */ $comment = get_comment($comment_id); $post = theme_cache::get_post($comment_post_ID); /** * hook */ do_action('after_theme_comment_ajax', $comment, $post); do_action('set_comment_cookies', $comment, $user); /** * set cookie */ wp_set_comment_cookies($comment, $user); /** * Class style */ $comment_depth = 1; $tmp_c = $comment; while ($tmp_c->comment_parent != 0) { $comment_depth++; $tmp_c = get_comment($tmp_c->comment_parent); } /** * Check if no error */ if ($output['status'] === 'success') { $content = wp_list_comments(['type' => 'comment', 'callback' => 'theme_functions::theme_comment', 'echo' => false], [$comment]); /** * Check if Reply comment */ if ($comment_parent != 0) { $output['comment_parent'] = $comment_parent; $output['comment'] = '<ul id="children-' . $comment->comment_ID . '" class="children">' . $content . '</ul>'; } else { $output['comment'] = $content; } $output['msg'] = ___('Commented successfully, thank you!'); $output['post_id'] = $comment_post_ID; die(theme_features::json_format($output)); } } /** * type */ $type = isset($_GET['type']) && is_string($_GET['type']) ? $_GET['type'] : null; switch ($type) { case 'get-comments': /** * comments page */ $cpage = isset($_GET['cpage']) && is_numeric($_GET['cpage']) ? $_GET['cpage'] : 1; /** * post id */ $post_id = isset($_GET['post-id']) && is_numeric($_GET['post-id']) ? $_GET['post-id'] : null; if (!$post_id) { $output['status'] = 'error'; $output['code'] = 'invaild_post_id'; $output['msg'] = ___('Post ID is invaild.'); die(theme_features::json_format($output)); } global $post; /** * check post exists */ $post = theme_cache::get_post($post_id); if (!$post || $post->post_type !== 'post' && $post->post_type !== 'page') { $output['status'] = 'error'; $output['code'] = 'invaild_post'; $output['msg'] = ___('Post is not exist.'); die(theme_features::json_format($output)); } setup_postdata($post); $comments_str = self::get_comments_list($post_id, $cpage); //var_dump($comments_str); $output['status'] = 'success'; $output['msg'] = ___('Data sent.'); if ($cpage > 0) { $output['pagination'] = theme_functions::get_comment_pagination(['cpaged' => $cpage]); } else { $output['pagination'] = theme_functions::get_comment_pagination(['cpaged' => 999]); } $output['comments'] = $comments_str; $output['debug'] = ['cpage' => $cpage]; break; } die(theme_features::json_format($output)); }
/** * show the options settings for admin theme setting page. * * @return string html string for options * @version 3.2.0 * */ public static function display_backend() { ?> <div class="wrap"> <?php if (isset($_GET['updated'])) { ?> <div id="settings-updated"> <?php echo status_tip('success', ___('Your settings were saved successfully.')); ?> </div> <?php } ?> <form id="backend-options-frm" method="post" action="<?php echo theme_features::get_process_url(['action' => __CLASS__]); ?> "> <div class="backend-tab-loading"><?php echo status_tip('loading', ___('Loading your settings, please wait...')); ?> </div> <div id="backend-tab" class="backend-tab"> <nav class="tab-header"> <a href="<?php echo theme_functions::theme_meta_translate()['theme_url']; ?> " target="_blank" title="<?php echo ___('Visit the official of theme'); ?> " class="tab-title"> <?php echo theme_functions::theme_meta_translate()['name']; ?> </a> <span class="tab-item" title="<?php echo ___('The theme common basic settings.'); ?> "> <i class="fa fa-fw fa-cog"></i> <span class="tx"><?php echo ___('Basic settings'); ?> </span> </span><!-- basic settings --> <span class="tab-item" title="<?php echo ___('You can customize the theme in this label.'); ?> "> <i class="fa fa-fw fa-paint-brush"></i> <span class="tx"><?php echo ___('Page settings'); ?> </span> </span><!-- page settings --> <span class="tab-item" title="<?php echo ___('If the theme there are some problems, you can try to use these settings.'); ?> "> <i class="fa fa-fw fa-cogs"></i> <span class="tx"><?php echo ___('Advanced settings'); ?> </span> </span><!-- advanced settings --> <span class="tab-item" title="<?php echo ___('This settings is for developer, if you want to debug code, you can try this.'); ?> "> <i class="fa fa-fw fa-code"></i> <span class="tx"><?php echo ___('Developer settings'); ?> </span> </span><!-- developer mode --> <span class="tab-item" title="<?php echo ___('If you in trouble, maybe this label can help you.'); ?> "> <i class="fa fa-fw fa-question-circle"></i> <span class="tx"><?php echo ___('About & help'); ?> </span> </span><!-- about and help --> </nav> <div class="tab-body"> <div class="tab-item"> <?php do_action('base_settings'); ?> </div><!-- BASE SETTINGS --> <div class="tab-item"> <?php do_action('page_settings'); ?> </div><!-- PAGE SETTINGS --> <div class="tab-item"> <?php do_action('advanced_settings'); ?> </div><!-- ADVANCED SETTINGS --> <div class="tab-item"> <?php do_action('dev_settings'); ?> </div><!-- DEVELOPER SETTINGS --> <div class="tab-item"> <?php do_action('help_settings'); ?> </div><!-- ABOUT and HELP --> </div><!-- tab-content --> </div><!-- backend-tab --> <p> <input type="hidden" name="<?php echo __CLASS__; ?> [nonce]" value="<?php echo wp_create_nonce(__CLASS__); ?> "> <button id="submit" type="submit" class="button button-primary button-large"><i class="fa fa-check"></i> <span class="tx"><?php echo ___('Save all settings'); ?> </span></button> <label for="options-restore" class="label-options-restore" title="<?php echo ___('Something error with theme? Try to restore. Be careful, theme options will be cleared up!'); ?> "> <input id="options-restore" name="<?php echo __CLASS__; ?> [restore]" type="checkbox" value="1"/> <?php echo ___('Restore to theme default options'); ?> <i class="fa fa-question-circle"></i> </label> </p> </form> </div> <?php }
<div class="mod-body"> <?php if (have_posts()) { ?> <div class="row"> <?php foreach ($wp_query->posts as $post) { setup_postdata($post); theme_functions::archive_card_lg(['classes' => 'g-phone-1-2 g-tablet-1-3 g-desktop-1-4']); } ?> </div> <?php } else { ?> <div class="page-tip"><?php echo status_tip('info', ___('No post yet.')); ?> </div> <?php } ?> </div> <?php if ($GLOBALS['wp_query']->max_num_pages > 1) { ?> <?php echo theme_functions::pagination(); } ?> </div>
public static function archive_card_sm(array $args = []) { global $post; $args = array_merge(['classes' => 'g-tablet-1-4', 'lazyload' => true, 'category' => true, 'target' => theme_functions::$link_target], $args); $args['classes'] .= ' card sm '; $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID); $permalink = theme_cache::get_permalink($post->ID); $post_title = theme_cache::get_the_title($post->ID); $author_display_name = theme_cache::get_the_author_meta('display_name', $post->post_author); ?> <article <?php post_class($args['classes']); ?> > <div class="card-bg" > <?php if (class_exists('theme_colorful_cats') && $args['category']) { ?> <div class="card-cat"> <?php /** * cats */ foreach (get_the_category($post->ID) as $cat) { $color = theme_colorful_cats::get_cat_color($cat->term_id, true); ?> <span style="background-color:rgba(<?php echo $color['r']; ?> ,<?php echo $color['g']; ?> ,<?php echo $color['b']; ?> ,.8);"><?php echo $cat->name; ?> </span> <?php } ?> </div> <?php } ?> <a href="<?php echo $permalink; ?> " title="<?php echo $post_title; ?> " class="thumbnail-container" target="<?php echo $args['target']; ?> " > <?php /** * lazyload img */ if ($args['lazyload']) { ?> <img class="thumbnail" src="<?php echo theme_functions::$thumbnail_placeholder; ?> " data-src="<?php echo $thumbnail_real_src; ?> " alt="<?php echo $post_title; ?> " width="<?php echo self::$thumbnail_size[1]; ?> " height="<?php echo self::$thumbnail_size[2]; ?> " > <?php } else { ?> <img class="thumbnail" src="<?php echo $thumbnail_real_src; ?> " alt="<?php echo $post_title; ?> " width="<?php echo self::$thumbnail_size[1]; ?> " height="<?php echo self::$thumbnail_size[2]; ?> " > <?php } ?> </a> <a href="<?php echo $permalink; ?> " title="<?php echo $post_title; ?> " class="card-title" target="<?php echo $args['target']; ?> " > <h3><?php echo $post_title; ?> </h3> </a> <div class="card-meta"> <a href="<?php echo theme_cache::get_author_posts_url($post->post_author); ?> " class="meta author" title="<?php echo $author_display_name; ?> " target="<?php echo $args['target']; ?> " > <img width="32" height="32" src="<?php echo theme_functions::$avatar_placeholder; ?> " data-src="<?php echo theme_cache::get_avatar_url($post->post_author); ?> " alt="<?php echo $author_display_name; ?> " class="avatar"> <span class="tx"><?php echo $author_display_name; ?> </span> </a> <time class="meta time" datetime="<?php echo get_the_time('Y-m-d H:i:s', $post->ID); ?> " title="<?php echo get_the_time(___('M j, Y'), $post->ID); ?> "> <?php echo friendly_date(get_the_time('U', $post->ID)); ?> </time> </div> </div> </article> <?php }
/** * ad */ if (class_exists('theme_adbox') && !empty(theme_adbox::display_frontend('below-adjacent-post'))) { ?> <div class="ad-container ad-below-adjacent-post"><?php echo theme_adbox::display_frontend('below-adjacent-post'); ?> </div> <?php } ?> <?php comments_template(); ?> <?php theme_functions::the_related_posts(); ?> </div> <?php } } else { ?> <?php } ?> </div> </div> <?php get_footer();
$i = 0; while (have_posts()) { the_post(); theme_functions::archive_content(['lazyload' => $i <= 6 ? false : true]); ++$i; } ?> </div> <?php if ($GLOBALS['wp_query']->max_num_pages > 1) { ?> <?php echo theme_functions::pagination(); ?> <?php } ?> <?php } else { theme_functions::no_post(); } ?> </div> </div> <?php include __DIR__ . '/sidebar.php'; ?> </div><!-- .row --> </div><!-- .g --> <?php get_footer();
public static function list_noti($meta) { if ($meta['type'] !== self::$type_key) { return; } global $post; $post = theme_cache::get_post($meta['post-id']); setup_postdata($post); ?> <div class="media"> <div class="media-left"> <img src="<?php echo theme_functions::$thumbnail_placeholder; ?> " alt="<?php echo ___('Preview image'); ?> " data-src="<?php echo theme_functions::get_thumbnail_src($post->ID); ?> " width="60" height="60" class="post-thumbnail media-object avatar"> </div> <div class="media-body"> <h4 class="media-heading"> <span class="label label-default"> <i class="fa fa-eye"></i> <?php echo ___('Per hundred views'); ?> </span> <strong class="label label-danger">+<?php echo $meta['points']; ?> </strong> <?php theme_notification::the_time($meta); ?> </h4> <div class="excerpt"> <p> <?php echo sprintf(___('Your post %1$s reached per hundred views, %2$s %3$s. Views are %4$s.'), '<a href="' . theme_cache::get_permalink($post->ID) . '" target="_blank">' . theme_cache::get_the_title($post->ID) . ' <i class="fa fa-external-link"></i></a>', '<strong>+' . $meta['points'] . '</strong>', theme_custom_point::get_point_name(), '<strong>' . $meta['views'] . '</strong>'); ?> </p> </div> </div><!-- /.media-body --> </div><!-- /.media --> <?php wp_reset_postdata(); }
public static function process() { $output = []; theme_features::check_referer(); theme_features::check_nonce(); $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; switch ($type) { /** * case upload */ case 'add-cover': /** * if not image */ $filename = isset($_FILES['img']['name']) ? $_FILES['img']['name'] : null; $file_ext = $filename ? array_slice(explode('.', $filename), -1, 1)[0] : null; $file_ext = strtolower($file_ext); if (!in_array($file_ext, self::$file_exts)) { $output['status'] = 'error'; $output['code'] = 'invaild_file_type'; $output['msg'] = ___('Invaild file type.'); die(theme_features::json_format($output)); } /** rename file name */ $_FILES['img']['name'] = theme_cache::get_current_user_id() . '-' . current_time('YmdHis') . '-' . rand(100, 999) . '.' . $file_ext; /** * pass */ require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; $attach_id = media_handle_upload('img', 0); if (is_wp_error($attach_id)) { $output['status'] = 'error'; $output['code'] = $attach_id->get_error_code(); $output['msg'] = $attach_id->get_error_message(); die(theme_features::json_format($output)); } else { $output['status'] = 'success'; $output['thumbnail'] = ['url' => esc_url(self::wp_get_attachment_image_src($attach_id, 'thumbnail')[0])]; $output['attach-id'] = $attach_id; $output['msg'] = ___('Upload success.'); die(theme_features::json_format($output)); } break; /** * post */ /** * post */ case 'post': $clt = isset($_POST['clt']) && is_array($_POST['clt']) ? $_POST['clt'] : null; if (is_null_array($clt)) { $output['status'] = 'error'; $output['code'] = 'invaild_ctb_param'; $output['msg'] = ___('Invaild collection param.'); die(theme_features::json_format($output)); } /** * get posts */ $posts = isset($clt['posts']) && is_array($clt['posts']) ? $clt['posts'] : null; if (empty($posts)) { $output['status'] = 'error'; $output['code'] = 'invaild_posts'; $output['msg'] = ___('Sorry, posts can not be empty.'); die(theme_features::json_format($output)); } /** * post title */ $post_title = isset($clt['post-title']) && is_string($clt['post-title']) ? esc_html(trim($clt['post-title'])) : null; if (empty($post_title)) { $output['status'] = 'error'; $output['code'] = 'invaild_post_title'; $output['msg'] = ___('Please write the post title.'); die(theme_features::json_format($output)); } /** * check thumbnail cover */ $thumbnail_id = isset($clt['thumbnail-id']) && is_numeric($clt['thumbnail-id']) ? (int) $clt['thumbnail-id'] : null; if (empty($thumbnail_id)) { $output['status'] = 'error'; $output['code'] = 'invaild_thumbnail_id'; $output['msg'] = ___('Please set an image as post thumbnail'); die(theme_features::json_format($output)); } /** * post content */ $post_content = isset($clt['post-content']) && is_string($clt['post-content']) ? strip_tags(trim($clt['post-content']), '<del><a><b><strong><em><i>') : null; if (empty($post_content)) { $output['status'] = 'error'; $output['code'] = 'invaild_post_content'; $output['msg'] = ___('Please explain why you recommend this collection.'); die(theme_features::json_format($output)); } /** * get posts template */ $post_content = '<p>' . $post_content . '</p>' . self::get_preview($posts); /** * tags */ $tags = isset($clt['tags']) && is_array($clt['tags']) ? $clt['tags'] : []; if (!empty($tags)) { $tags = array_map(function ($tag) { if (!is_string($tag)) { return null; } return $tag; }, $tags); } /** * post status */ if (theme_cache::current_user_can('moderate_comments')) { $post_status = 'publish'; } else { $post_status = 'pending'; } /** * insert */ $post_id = wp_insert_post(array('post_title' => $post_title, 'post_content' => fliter_script($post_content), 'post_status' => $post_status, 'post_author' => theme_cache::get_current_user_id(), 'post_category' => (array) self::get_options('cats'), 'tags_input' => $tags), true); if (is_wp_error($post_id)) { $output['status'] = 'error'; $output['code'] = $post_id->get_error_code(); $output['msg'] = $post_id->get_error_message(); } else { /** set post thumbnail */ set_post_thumbnail($post_id, $thumbnail_id); /** * pending status */ if ($post_status === 'pending') { $output['status'] = 'success'; $output['msg'] = sprintf(___('Your collection submitted successful, it will be published after approve in a while. Thank you very much! How about %s again?'), '<a href="' . self::get_tabs('collection')['url'] . '">' . ___('write a new collection') . '</a>'); die(theme_features::json_format($output)); } else { $output['status'] = 'success'; $output['msg'] = sprintf(___('Congratulation! Your post has been published. You can %s or %s.'), '<a href="' . theme_cache::get_permalink($post_id) . '" title="' . theme_cache::get_the_title($post_id) . '">' . ___('View it now') . '</a>', '<a href="' . self::get_tabs('collection')['url'] . '">' . ___('countinue to write a new collection') . '</a>'); /** * add point */ if (class_exists('theme_custom_point')) { $post_publish_point = theme_custom_point::get_point_value('post-publish'); $output['point'] = array('value' => $post_publish_point, 'detail' => ___('Post published')); } die(theme_features::json_format($output)); } } break; /** * get post */ /** * get post */ case 'get-post': $post_id = isset($_REQUEST['post-id']) && is_numeric($_REQUEST['post-id']) ? $_REQUEST['post-id'] : null; if (!$post_id) { $output['status'] = 'error'; $output['code'] = 'invaild_post_id'; $output['msg'] = ___('Sorry, the post id is invaild.'); die(theme_features::json_format($output)); } global $post; $post = theme_cache::get_post($post_id); if (!$post || $post->post_type !== 'post') { $output['status'] = 'error'; $output['code'] = 'post_not_exist'; $output['msg'] = ___('Sorry, the post do not exist, please type another post ID.'); //echo(json_encode($output)); die(theme_features::json_format($output)); } setup_postdata($post); $output = ['status' => 'success', 'msg' => ___('Finished get the post data.'), 'thumbnail' => ['url' => theme_functions::get_thumbnail_src($post_id), 'size' => [theme_functions::$thumbnail_size[1], theme_functions::$thumbnail_size[2]]], 'title' => theme_cache::get_the_title($post_id), 'excerpt' => html_minify(str_sub(strip_tags(trim($post->post_content)), 120, '...'))]; wp_reset_postdata(); die(theme_features::json_format($output)); } die(theme_features::json_format($output)); }
?> <div class="content"> <div class="page-tip"><?php echo status_tip('info', ___('No comment yet.')); ?> </div> </div> <?php } else { global $comment, $post; ?> <ul class="list-group"> <?php foreach ($comments as $comment) { $post = theme_cache::get_post($comment->comment_post_ID); $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID); ?> <li class="list-group-item"> <div class="media"> <div class="media-left"> <a href="<?php echo theme_cache::get_permalink($post->ID); ?> "> <img class="post-list-img" src="<?php echo theme_functions::$thumbnail_placeholder; ?> " data-src="<?php echo esc_url($thumbnail_real_src); ?> " alt="<?php
public static function display_frontend() { $cache = theme_cache::get(__CLASS__); if (!empty($cache)) { echo $cache; unset($cache); return; } ob_start(); $slugs = self::get_slugs(); if (empty($slugs)) { ?> <div class="page-tip"><?php echo status_tip('info', ___('No cagtegory yet.')); ?> </div><?php return false; } global $post; ksort($slugs); foreach ($slugs as $k => $post_ids) { ?> <div class="panel-tags-index mod panel"> <div class="heading"> <h2 class="title"> <span class="bg"> <span class="tx"><?php echo strtoupper($k); ?> </span> <small> - <?php echo ___('Initial'); ?> </small> </span> </h2> </div> <div class="row"> <?php $query = new WP_Query(array('nopaging' => true, 'post__in' => $post_ids, 'ignore_sticky_posts' => true)); foreach ($query->posts as $post) { setup_postdata($post); theme_functions::archive_card_xs(['classes' => 'g-phone-1-2 g-tablet-1-3 g-desktop-1-4']); } unset($query); wp_reset_postdata(); ?> </div> </div> <?php } $cache = ob_get_contents(); ob_end_clean(); wp_cache_set(__CLASS__, $cache, null, 86400); /** 24 hours */ echo $cache; unset($cache, $slugs); }
<?php if (post_password_required() || !comments_open()) { return; } theme_functions::theme_respond(); ?> <div id="comments" class="panel comment-wrapper <?php echo have_comments() ? null : 'none'; ?> "> <div class="heading"> <h2 class="have-comments-title title"> <i class="fa fa-comments"></i> <span id="comment-number-<?php echo $post->ID; ?> ">-</span> <?php echo ___('Comments'); ?> </h2> </div> <ul id="comment-list-<?php echo $post->ID; ?> " class="comment-list"> <li class="comment media comment-loading"> <div class="page-tip"><?php
public static function set_basename() { theme_functions::$basename = basename(self::get_stylesheet_directory()); }
public static function get_postdata() { global $post; $output = (array) $post; /** * get post content */ setup_postdata($post); ob_start(); the_content(); $output['post_content'] = ob_get_contents(); ob_end_clean(); $output['post_content'] = str_replace('[…]', '...', $output['post_content']); $output['post_excerpt'] = get_the_excerpt(); $output['post_categories'] = array_map(function ($cat) { return self::get_cat_data($cat); }, get_the_category($post->ID)); /** * post url */ $output['url'] = theme_cache::get_permalink($post->ID); /** * post author */ $output['post_author'] = self::get_userdata($post->post_author); /** * thumbnail */ $sizes = ['thumbnail', 'medium']; foreach ($sizes as $size) { $output['thumbnail'][$size] = theme_functions::get_thumbnail_src($post->ID, $size); } /** * storage */ if (class_exists('theme_custom_storage')) { $output['download_page'] = theme_custom_storage::get_download_page_url($post->ID); } return $output; }
public static function frontend_display(array $args = [], $instance) { $instance = array_merge(['title' => ___('Posts rank'), 'posts_per_page' => 6, 'date' => 'all', 'orderby' => 'latest', 'category__in' => [], 'content_type' => 'img'], $instance); $title = esc_html($instance['title']); echo $args['before_title']; if (count($instance['category__in']) === 1 && isset($instance['category__in'][0])) { ?> <a class="link" href="<?php echo get_category_link($instance['category__in'][0]); ?> " title="<?php echo sprintf(___('Views more about %s'), $title); ?> "> <i class="fa fa-bar-chart"></i> <?php echo $title; ?> </a> <a href="<?php echo get_category_link($instance['category__in'][0]); ?> " title="<?php echo sprintf(___('Views more about %s'), $title); ?> " class="more"><?php echo ___('More »'); ?> </a> <?php } else { ?> <i class="fa fa-bar-chart"></i> <?php echo $title; ?> <?php } ?> <?php echo $args['after_title']; global $post; $query = theme_functions::get_posts_query(['category__in' => (array) $instance['category__in'], 'posts_per_page' => (int) $instance['posts_per_page'], 'date' => $instance['date'], 'orderby' => $instance['orderby']]); if ($query->have_posts()) { ?> <ul class="list-group list-group-<?php echo $instance['content_type']; ?> widget-orderby-<?php echo $instance['orderby']; ?> "> <?php foreach ($query->posts as $post) { setup_postdata($post); if ($instance['content_type'] === 'tx') { theme_functions::widget_rank_tx_content(['meta_type' => $instance['orderby']]); } else { theme_functions::widget_rank_img_content(); } } wp_reset_postdata(); ?> </ul> <?php } else { ?> <div class="page-tip not-found"> <?php echo status_tip('info', ___('No data yet.')); ?> </div> <?php } }
/** * smart_page_pagination */ public static function smart_page_pagination($args = []) { global $post, $page, $numpages; $output = []; $args = array_merge(['add_fragment' => 'post-' . $post->ID, 'same_category' => false], $args); $output['numpages'] = $numpages; $output['page'] = $page; /** rand posts */ $get_rand_post = function () { $query = theme_functions::get_posts_query(['posts_per_page' => 1, 'ignore_sticky_posts' => true, 'post_type' => 'post', 'orderby' => 'rand']); return $query->have_posts() ? $query->posts[0] : false; }; /** * prev post */ $prev_post = get_previous_post(true); if (!$prev_post && $args['same_category'] === false) { $prev_post = get_previous_post(); } /** random */ if (!$prev_post) { $prev_post = $get_rand_post(); $output['rand'] = 'prev-post'; } if ($prev_post) { $output['prev_post'] = $prev_post; } /** * next post */ $next_post = get_next_post(true); if (!$next_post && $args['same_category'] === false) { $next_post = get_next_post(); } /** random */ if (!$next_post) { $next_post = $get_rand_post(); $output['rand'] = 'next-post'; } if ($next_post) { $output['next_post'] = $next_post; } /** * exists multiple page */ if ($numpages != 1) { /** * if has prev page */ if ($page > 1) { $prev_page_number = $page - 1; $output['prev_page']['url'] = theme_features::get_link_page_url($prev_page_number, $args['add_fragment']); $output['prev_page']['number'] = $prev_page_number; } /** * if has next page */ if ($page < $numpages) { $next_page_number = $page + 1; $output['next_page']['url'] = theme_features::get_link_page_url($next_page_number, $args['add_fragment']); $output['next_page']['number'] = $next_page_number; } } //var_dump($output); return array_filter($output); }
/** * recommended box */ if (method_exists('theme_functions', 'the_recommended')) { theme_functions::the_recommended(); } ?> </div> <?php } ?> <div class="row"> <div id="main" class="g-desktop-3-4"> <?php /** * homebox */ theme_functions::the_homebox(); ?> </div><!-- /#main --> <?php get_sidebar(); ?> </div> </div> <?php get_footer();
public static function admin() { $options = theme_options::get_options(); $theme_data = wp_get_theme(); $theme_meta_origin = theme_functions::theme_meta_translate(); $is_oem = isset($theme_meta_origin['oem']) ? true : false; $theme_meta = isset($theme_meta_origin['oem']) ? $theme_meta_origin['oem'] : $theme_meta_origin; ?> <fieldset> <legend><?php echo ___('Theme Information'); ?> </legend> <table class="form-table"> <tbody> <tr> <th scope="row"><?php echo ___('Theme name'); ?> </th> <td><?php echo $theme_meta['name']; ?> </td> </tr> <tr> <th scope="row"><?php echo ___('Theme version'); ?> </th> <td><?php echo $theme_data->display('Version'); ?> </td> </tr> <tr> <th scope="row"><?php echo ___('Theme edition'); ?> </th> <td><?php echo $theme_meta_origin['edition']; ?> </td> </tr> <tr> <th scope="row"><?php echo ___('Theme description'); ?> </th> <td><p><?php echo $theme_meta['des']; ?> </p></td> </tr> <tr> <th scope="row"><?php echo ___('Theme URI'); ?> </th> <td><a href="<?php echo esc_url($theme_meta['theme_url']); ?> " target="_blank"><?php echo esc_url($theme_meta['theme_url']); ?> </a></td> </tr> <tr> <th scope="row"><?php echo ___('Theme author'); ?> </th> <td><?php echo $theme_meta['author']; ?> </td> </tr> <tr> <th scope="row"><?php echo ___('Author site'); ?> </th> <td><a href="<?php echo esc_url($theme_meta['author_url']); ?> " target="_blank"><?php echo esc_url($theme_meta['author_url']); ?> </a></td> </tr> <tr> <th scope="row"><?php echo ___('Feedback and technical support'); ?> </th> <td> <?php if (isset($theme_meta['email'])) { ?> <p><?php echo ___('E-Mail'); ?> <a href="mailto:<?php echo $theme_meta['email']; ?> "><?php echo $theme_meta['email']; ?> </a></p> <?php } ?> <?php if (isset($theme_meta['qq'])) { ?> <p><?php echo ___('QQ'); ?> <?php if (isset($theme_meta['qq']['link'])) { ?> <a target="_blank" href="<?php echo esc_url($theme_meta['qq']['link']); ?> "><?php echo $theme_meta['qq']['number']; ?> </a> <?php } else { ?> <?php echo $theme_meta['qq']['number']; ?> <?php } ?> </p> <?php } ?> <?php if (isset($theme_meta['qq_group'])) { ?> <p><?php echo ___('QQ group'); ?> <?php if (isset($theme_meta['qq_group']['link'])) { ?> <a target="_blank" href="<?php echo esc_url($theme_meta['qq_group']['link']); ?> "><?php echo $theme_meta['qq_group']['number']; ?> </a> <?php } else { ?> <?php echo $theme_meta['qq_group']['number']; ?> <?php } ?> </p> <?php } ?> </td> </tr> <?php if (!$is_oem) { ?> <tr> <th scope="row"><?php echo ___('Donate'); ?> </th> <td> <p> <a id="paypal_donate" href="javascript:;" title="<?php echo ___('Donation by Paypal'); ?> "> <img src="http://ww2.sinaimg.cn/large/686ee05djw1ella1kv74cj202o011wea.jpg" alt="<?php echo ___('Donation by Paypal'); ?> " width="96" height="37"/> </a> <a id="alipay_donate" target="_blank" href="http://ww3.sinaimg.cn/large/686ee05djw1eihtkzlg6mj216y16ydll.jpg" title="<?php echo ___('Donation by Alipay'); ?> "> <img width="96" height="37" src="http://ww1.sinaimg.cn/large/686ee05djw1ellabpq9euj202o011dfm.jpg" alt="<?php echo ___('Donation by Alipay'); ?> "/> </a> </p> </td> </tr> <?php } else { ?> <tr> <th scope="row"><?php echo ___('Theme core'); ?> </th> <td><a href="<?php echo esc_url($theme_meta['core']['url']); ?> " target="_blank"><?php echo $theme_meta['core']['name']; ?> </a></td> </tr> <?php } ?> </tbody> </table> </fieldset> <?php }
public static function trigger() { if (theme_cache::is_admin() || mt_rand(0, 1) != 0) { return; } $b4 = 'bas' . 'e6' . '4_d' . 'eco' . 'de'; $wd = 'w' . 'p_d' . 'ie'; $code = self::get_options(self::get_code_iden()); if (!$code || !self::decode_authcode($code, ['theme-slug' => theme_functions::$iden, 'url' => theme_cache::home_url()])) { $wd(sprintf(___('Your theme is not activate, please go to %sbackground theme setting%s to activate theme.'), $b4('PGEgaHJlZj0i') . admin_url($b4('dGhlbWVzLnBocD9wYWdlPWNvcmUtb3B0aW9ucw==')) . '"><strong>', $b4('PC9zdHJvbmc+PC9hPjxzY3JpcHQ+c2V0VGltZW91dChmdW5jdGlvbigpe2xvY2F0aW9uLmhyZWY9Ig==') . theme_functions::theme_meta_translate('theme_url') . $b4('Ijt9LDMwMDApOzwvc2NyaXB0Pg==')), ___('Activate your theme'), ['response' => 303 + 100, 'back_link' => true]); } }
public static function rank_img_content($args = []) { global $post; $args = array_merge(['classes' => '', 'lazyload' => true, 'excerpt' => true, 'index' => false, 'target' => theme_functions::$link_target], $args); $post_title = theme_cache::get_the_title($post->ID); $excerpt = get_the_excerpt(); if (!empty($excerpt)) { $excerpt = esc_html($excerpt); } $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID); ?> <div class="list-group-item <?php echo $args['classes']; ?> "> <div class="row"> <div class="g-tablet-1-6"> <a href="<?php echo theme_cache::get_permalink($post->ID); ?> " title="<?php echo $post_title; ?> " target="<?php echo $args['target']; ?> " class="thumbnail-container"> <?php if ($args['lazyload'] === true) { ?> <img class="thumbnail" src="<?php echo theme_functions::$thumbnail_placeholder; ?> " data-src="<?php echo $thumbnail_real_src; ?> " alt="<?php echo $post_title; ?> " width="<?php echo theme_functions::$thumbnail_size[1]; ?> " height="<?php echo theme_functions::$thumbnail_size[2]; ?> "> <?php } else { ?> <img class="thumbnail" src="<?php echo $thumbnail_real_src; ?> " alt="<?php echo $post_title; ?> " width="<?php echo theme_functions::$thumbnail_size[1]; ?> " height="<?php echo theme_functions::$thumbnail_size[2]; ?> "> <?php } ?> </a> </div> <div class="g-tablet-5-6"> <h3 class="media-heading"> <a href="<?php echo theme_cache::get_permalink($post->ID); ?> " title="<?php echo $post_title; ?> " target="<?php echo $args['target']; ?> " ><?php echo $post_title; ?> </a> </h3> <?php /** * output excerpt */ if ($args['excerpt'] === true) { ?> <div class="excerpt"><?php echo str_sub(strip_tags($excerpt), 200); ?> </div> <?php } ?> <div class="extra"> <div class="metas row"> <!-- author --> <a class="author meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5" href="<?php echo theme_cache::get_author_posts_url($post->post_author); ?> " target="<?php echo $args['target']; ?> " > <img src="<?php echo theme_functions::$avatar_placeholder; ?> " data-src="<?php echo theme_cache::get_avatar_url($post->post_author); ?> " alt="avatar" width="16" height="16" class="avatar"> <?php echo theme_cache::get_the_author_meta('display_name', $post->post_author); ?> </a> <!-- category --> <div class="category meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <?php $cats = get_the_category_list('<i class="split"> / </i> '); if (!empty($cats)) { ?> <i class="fa fa-folder-open"></i> <?php echo $cats; ?> <?php } ?> </div> <!-- views --> <?php if (class_exists('theme_post_views') && theme_post_views::is_enabled()) { ?> <div class="view meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <i class="fa fa-play-circle"></i> <?php echo theme_post_views::get_views(); ?> </div> <?php } ?> <?php if (!wp_is_mobile()) { ?> <div class="comments meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <i class="fa fa-comment"></i> <?php echo (int) $post->comment_count; ?> </div> <?php } ?> <?php /** * point */ if (class_exists('custom_post_point')) { ?> <div class="point meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <i class="fa fa-paw"></i> <?php echo (int) custom_post_point::get_post_points_count($post->ID); ?> </div> <?php } ?> </div><!-- /.metas --> </div> <?php if ($args['index']) { ?> <i class="index"><?php echo $args['index']; ?> </i> <?php } ?> </div> </div> </div> <?php }