public static function process() { theme_features::check_referer(); $post_id = isset($_GET['post-id']) && is_numeric($_GET['post-id']) ? (int) $_GET['post-id'] : false; if (!$post_id) { die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_post_id', 'msg' => ___('Sorry, post id is invaild.')])); } global $post, $page; /** * post */ $post = theme_cache::get_post($post_id); if (!$post) { die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, the post does not exist.')])); } /** * page */ $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int) $_GET['page'] : false; if (!$page) { die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_page_number', 'msg' => ___('Sorry, page number is invaild.')])); } set_query_var('page', $page); setup_postdata($post); ob_start(); if (class_exists('theme_img_lazyload')) { remove_filter('the_content', 'theme_img_lazyload::the_content'); } the_content(); $content = html_minify(ob_get_contents()); ob_end_clean(); die(theme_features::json_format(['status' => 'success', 'content' => $content])); }
public static function is_page() { static $cache = null; if ($cache === null) { $cache = theme_cache::is_page(self::$page_slug) && self::get_tabs(get_query_var('tab')); } return $cache; }
/** * frontend css */ public static function frontend_enqueue_css() { $frontend_css = theme_cache::is_user_logged_in() ? 'frontend-logged' : 'frontend'; $css = ['frontend' => ['deps' => ['awesome'], 'url' => theme_features::get_theme_css($frontend_css)], 'awesome' => ['deps' => [], 'url' => '//cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css', 'version' => null]]; foreach ($css as $k => $v) { wp_enqueue_style($k, $v['url'], isset($v['deps']) ? $v['deps'] : [], self::get_version($v)); } }
public static function get_url() { static $cache = null; if ($cache === null) { $cache = theme_cache::get_permalink(theme_cache::get_page_by_path(self::$page_slug)->ID); } return $cache; }
public static function process() { if (!theme_cache::current_user_can('manage_options')) { die(___('You have not permission.')); } theme_options::set_options(self::$iden, $_SERVER['REQUEST_TIME']); header('location: ' . theme_options::get_url() . '&' . self::$iden); die; }
public static function init() { if (!theme_cache::current_user_can('manage_options')) { return; } self::$checker_url = ___('http://update.inn-studio.com') . '/?action=get_update&slug=' . theme_functions::$iden; add_filter('site_transient_update_themes', __CLASS__ . '::check_for_update'); add_filter('upgrader_source_selection', __CLASS__ . '::filter_upgrader_source_selection', 10, 3); add_filter('upgrader_pre_install', __CLASS__ . '::filter_upgrader_pre_install', 10, 2); }
public static function init() { self::$cache_base_key = theme_functions::$iden; add_action('advanced_settings', __CLASS__ . '::display_backend'); add_action('wp_ajax_' . __CLASS__, __CLASS__ . '::process'); /** * When update menu */ add_filter('pre_set_theme_mod_nav_menu_locations', function ($return) { self::delete_keys('nav-menu'); return $return; }); /** * When update widget */ add_filter('widget_update_callback', function ($instance) { self::delete_keys('dynamic-sidebar'); return $instance; }); /** * When update option for widget */ add_action('update_option_sidebars_widgets', function () { self::delete_keys('dynamic-sidebar'); }); /** * when post delete */ add_action('delete_post', function ($post_id) { $post = self::get_post($post_id); if ($post->type !== 'page') { return; } $caches = (array) wp_cache_get('pages_by_path'); if (isset($caches[$post->post_name])) { unset($caches[$post->post_name]); wp_cache_set('pages_by_path', $caches); } }); /** * when post save */ add_action('save_post', function ($post_id) { $post = self::get_post($post_id); if ($post->type !== 'page') { return; } $caches = (array) wp_cache_get('pages_by_path'); if (!isset($caches[$post->post_name])) { $caches[$post->post_name] = $post_id; wp_cache_set('pages_by_path', $caches); } }); }
public static function display($args = []) { global $post; $opt = self::get_options(); $img_url = theme_features::get_thumbnail_src($post->ID); $defaults = array('post_title_text' => theme_cache::get_the_title($post->ID), 'post_url' => theme_cache::get_permalink($post->ID), 'blog_name' => theme_cache::get_bloginfo('name'), 'blog_url' => theme_cache::home_url(), 'img_url' => esc_url($img_url), 'post_excerpt' => esc_attr(mb_substr(html_minify(strip_tags(get_the_excerpt())), 0, 120)), 'post_content' => esc_attr(mb_substr(html_minify(strip_tags(get_the_content())), 0, 120)), 'author' => theme_cache::get_the_author_meta('display_name', $post->post_author)); $output_keywords = array_merge($defaults, $args); $tpl_keywords = array('%post_title_text%', '%post_url%', '%blog_name%', '%blog_url%', '%img_url%', '%post_excerpt%', '%post_content%', '%author%'); $post_share_code = stripslashes(str_ireplace($tpl_keywords, $output_keywords, $opt['code'])); echo $post_share_code; }
public static function init() { add_filter('wp_handle_upload_prefilter', __CLASS__ . '::compress_jpeg_quality', 1, 99); 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_cache::current_user_can('manage_options')) { return; } add_filter('wp_handle_upload_prefilter', __CLASS__ . '::filter_wp_handle_upload_prefilter'); }
public static function page_create() { if (!theme_cache::current_user_can('manage_options')) { return false; } $page_slugs = array(self::$page_slug => array('post_content' => '[no-content]', 'post_name' => 'account', 'post_title' => ___('Account'), 'page_template' => 'page-' . self::$page_slug . '.php')); $defaults = array('post_content' => '[post_content]', 'post_name' => null, 'post_title' => null, 'post_status' => 'publish', 'post_type' => 'page', 'comment_status' => 'closed'); foreach ($page_slugs as $k => $v) { theme_cache::get_page_by_path($k) || wp_insert_post(array_merge($defaults, $v)); } }
public static function get_comment_text($comment_content, $comment) { /** * has parent */ if ($comment->comment_parent != 0) { $parent_comment = theme_cache::get_comment($comment->comment_parent); $parent_author = theme_cache::get_comment_author($parent_comment->comment_ID); $comment_content = '<a href="' . theme_cache::get_permalink($parent_comment->comment_post_ID) . '#comment-' . $parent_comment->comment_ID . '" class="at" rel="nofollow">@' . $parent_author . '</a> ' . $comment_content; } return $comment_content; }
/** * process */ public static function process() { if (!theme_cache::current_user_can('manage_options')) { return false; } @ini_set('max_input_nesting_level', '10000'); @ini_set('max_execution_time', 0); remove_dir(theme_features::get_stylesheet_directory() . theme_features::$basedir_js_min); theme_features::minify_force(theme_features::get_stylesheet_directory() . theme_features::$basedir_js_src); remove_dir(theme_features::get_stylesheet_directory() . theme_features::$basedir_css_min); theme_features::minify_force(theme_features::get_stylesheet_directory() . theme_features::$basedir_css_src); theme_features::minify_force(theme_features::get_stylesheet_directory() . theme_features::$basedir_addons); theme_file_timestamp::set_timestamp(); wp_redirect(add_query_arg(__CLASS__, 1, theme_options::get_url())); die; }
public static function get_tabs($key, $author_id) { static $caches = [], $baseurl = []; if (isset($caches[$author_id])) { if ($key) { return isset($caches[$author_id][$key]) ? $caches[$author_id][$key] : null; } return $caches[$author_id]; } if (!isset($baseurl[$author_id])) { $baseurl[$author_id] = theme_cache::get_author_posts_url($author_id); } $caches[$author_id] = array('profile' => array('text' => ___('Profile'), 'icon' => 'newspaper-o', 'url' => esc_url($baseurl[$author_id])), 'works' => array('text' => ___('Works'), 'icon' => 'file-text', 'url' => esc_url(add_query_arg('tab', 'works', $baseurl[$author_id])), 'count' => self::get_count('works', $author_id)), 'comments' => array('text' => ___('Comments'), 'icon' => 'comments', 'url' => esc_url(add_query_arg('tab', 'comments', $baseurl[$author_id])), 'count' => self::get_count('comments', $author_id))); if (class_exists('custom_post_point')) { $caches[$author_id]['rates'] = array('text' => ___('Rates'), 'icon' => 'star', 'url' => esc_url(add_query_arg('tab', 'rates', $baseurl[$author_id])), 'count' => self::get_count('followers_count', $author_id)); } if ($key) { return isset($caches[$author_id][$key]) ? $caches[$author_id][$key] : null; } return $caches[$author_id]; }
public static function admin_header_image() { ?> <div id="banner" style="background-image:url(<?php echo get_header_image(); ?> )"> <?php if (display_header_text()) { ?> <h2><?php echo theme_cache::get_bloginfo('description'); ?> </h2> </div> <?php } ?> </div> <?php }
function widget($args, $instance) { $instance = array_merge(self::get_default_options(), $instance); echo $args['before_widget']; $comments = get_comments(array('status' => 'approve', 'number' => isset($instance['number']) ? (int) $instance['number'] : 6, 'type' => 'comment')); if (!empty($instance['title'])) { echo $args['before_title']; ?> <i class="fa fa-comments-o"></i> <?php echo $instance['title']; echo $args['after_title']; } if (!empty($comments)) { global $comment; $comment_bak = $comment; ?> <ul class="list-group"> <?php foreach ($comments as $comment) { /** * cache */ static $caches = []; /** author_name */ if (!isset($caches['author_name'][$comment->comment_author])) { $caches['author_name'][$comment->comment_author] = esc_html(get_comment_author()); } /** avatar placeholder */ if (!isset($caches['avatar_placeholder'])) { $caches['avatar_placeholder'] = theme_functions::$avatar_placeholder; } /** comment text */ $comment_text = str_sub(strip_tags(preg_replace('/<img[^>]+>/i', '[' . ___('Image') . ']', get_comment_text($comment->comment_ID))), 35); ?> <li class="list-group-item"> <a class="media tooltip top" href="<?php echo theme_cache::get_permalink($comment->comment_post_ID); ?> #comment-<?php echo $comment->comment_ID; ?> " title="<?php echo theme_cache::get_the_title($comment->comment_post_ID); ?> "> <div class="media-left"> <img class="avatar media-object" data-src="<?php echo esc_url(theme_cache::get_avatar_url($comment)); ?> " src="<?php echo $caches['avatar_placeholder']; ?> " alt="<?php echo $caches['author_name'][$comment->comment_author]; ?> " width="<?php echo self::$avatar_size; ?> " height="<?php echo self::$avatar_size; ?> "/> </div> <div class="media-body"> <h4 class="media-heading"> <span class="author"><?php echo $caches['author_name'][$comment->comment_author]; ?> </span> <time datetime="<?php echo get_comment_time('c'); ?> "> <small><?php echo friendly_date(get_comment_time('U')); ?> </small> </time> </h4> <div class="text"><?php echo $comment_text; ?> </div> </div> </a> </li> <?php } ?> </ul> <?php $comment = $comment_bak; } else { ?> <div class="content"> <div class="page-tip"><?php echo status_tip('info', ___('No any comment yet.')); ?> </div> </div> <?php } echo $args['after_widget']; }
/** * Redirect */ public static function redirect() { $url = self::has_url(); if (!theme_cache::current_user_can('manage_options') && $url) { header("Location: {$url}"); die; } }
public static function process() { //theme_features::check_nonce(); theme_features::check_referer(); $output = []; $type = isset($_REQUEST['type']) && is_string($_REQUEST['type']) ? $_REQUEST['type'] : null; switch ($type) { /** * test */ case 'test': if (!theme_cache::current_user_can('manage_options')) { die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_permission', 'msg' => ___('Sorry, your permission is invaild.')])); } $test = isset($_POST['test']) && filter_var($_POST['test'], FILTER_VALIDATE_EMAIL) ? $_POST['test'] : false; if (!$test) { die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_test_mail', 'msg' => ___('Sorry, test mail is invaild.')])); } self::$debug = true; ob_start(); ?> <pre><?php echo wp_mail($test, ___('This is a test email.'), ___('This is a test email generated by your blog.')); ?> </pre> <?php $mail = ob_get_contents(); ob_end_clean(); die(theme_features::json_format(['status' => 'info', 'code' => 'unknow', 'msg' => $mail])); default: die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_param', 'msg' => ___('Sorry, param is invaild.')])); } }
public static function recent_posts() { $posts_per_page = 5; ?> <div class="panel"> <div class="heading"> <i class="fa fa-clock-o"></i> <?php echo ___('My recent posts'); ?> </div> <?php global $post; $query = new WP_Query(array('posts_per_page' => $posts_per_page, 'author' => theme_cache::get_current_user_id())); if ($query->have_posts()) { ?> <ul class="list-group"> <?php foreach ($query->posts as $post) { setup_postdata($post); ?> <li class="list-group-item"> <a href="<?php echo theme_cache::get_permalink($post->ID); ?> "><?php echo theme_cache::get_the_title($post->ID); ?> <small><?php echo friendly_date(get_the_time('U')); ?> </small></a> </li> <?php } wp_reset_postdata(); ?> </ul> <?php } else { ?> <div class="content"><?php echo status_tip('info', ___('No posts yet')); ?> </div> <?php } ?> </div> <?php }
<div class="panel"> <div class="content"> <?php echo theme_custom_point::get_point_des(); ?> <div class="media"> <div class="media-left"> <img class="media-object" src="<?php echo theme_custom_point::get_point_img_url(); ?> " alt=""> </div> <div class="media-body"> <h4 class="media-heading"> <strong class="total-point"><?php echo number_format(theme_custom_point::get_point(theme_cache::get_current_user_id())); ?> </strong> </h4> </div> </div> </div><!-- /.content --> <?php $history_list = theme_custom_point::get_history_list(array('posts_per_page' => 20)); if (empty($history_list)) { ?> <div class="content"> <div class="page-tip"><?php echo status_tip('info', ___('Your have not any history yet.')); ?> </div>
<div class="panel"> <?php $current_user_id = theme_cache::get_current_user_id(); $notis = theme_notification::get_notifications(array('user_id' => $current_user_id)); $unreads = theme_notification::get_notifications(array('user_id' => $current_user_id, 'type' => 'unread')); if (!empty($notis)) { ?> <ul class="list-group history-group"> <?php foreach ($notis as $k => $noti) { /** * Check the noti is read or unread */ if (isset($noti['id']) && isset($unreads[$noti['id']])) { $unread_class = ' unread list-group-item-info'; } else { $unread_class = null; } ?> <li class="list-group-item type-<?php echo $noti['type']; ?> <?php echo $unread_class; ?> "> <?php do_action('list_noti', $noti); ?> </li><!-- /.list-group-item --> <?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 filter_the_content($content) { if (!theme_cache::is_attachment()) { return $content; } global $post; $post_title = theme_cache::get_the_title($post->post_parent); if (!wp_attachment_is_image($post->ID)) { return $content; } $current_img_full = wp_get_attachment_image_src($post->ID, 'full'); $current_img_thumbnail = wp_get_attachment_image_src($post->ID, 'thumbnail'); $children = get_children(['post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'order' => 'ASC']); $children = array_values($children); $count = count($children); $child_posts = []; $current_post_index = 0; for ($i = 0; $i < $count; ++$i) { $child_img = wp_get_attachment_image_src($children[$i]->ID, 'thumbnail'); $child_posts[$i] = ['id' => $children[$i]->ID, 'permalink' => theme_cache::get_permalink($children[$i]->ID) . '#main', 'src' => $child_img[0], 'w' => $child_img[1], 'h' => $child_img[2]]; if ($children[$i]->ID == $post->ID) { $current_post_index = $i; } } unset($child_img); ob_start(); ?> <div class="attachment-slide"> <div class="attachment-slide-content"> <?php /** if current is last post */ if ($current_post_index == $count - 1) { $url_next = 'javascript:;'; $title_next = ___('Already last page'); } else { $url_next = $child_posts[$current_post_index + 1]['permalink']; $title_next = ___('Next page'); } ?> <a href="<?php echo $url_next; ?> " title="<?php echo $title_next; ?> "> <img src="<?php echo $current_img_full[0]; ?> " alt="" width="<?php echo $current_img_full[1]; ?> " height="<?php echo $current_img_full[2]; ?> "> </a> </div> <div class="attachment-slide-thumbnail"> <?php for ($i = 0; $i < $count; ++$i) { $class_active = $post->ID === $child_posts[$i]['id'] ? 'active' : null; ?> <a class="<?php echo $class_active; ?> " href="<?php echo $child_posts[$i]['permalink']; ?> "> <img src="<?php echo $child_posts[$i]['src']; ?> " alt="<?php echo $post_title; ?> " width="<?php echo $child_posts[$i]['w']; ?> " height="<?php echo $child_posts[$i]['h']; ?> "> </a> <?php } ?> </div> </div> <?php $content = ob_get_contents(); ob_end_clean(); return $content; }
if (theme_cache::is_home()) { ?> <div class="widget panel links-container"> <div class="heading"> <h2 class="widget-title"> <i class="fa fa-link"></i> <?php echo ___('Links'); ?> </h2> </div> <div class="content"> <?php /** * links */ theme_cache::wp_nav_menu(['theme_location' => 'links-footer', 'container' => 'nav', 'menu_class' => 'menu', 'menu_id' => 'links-footer', 'fallback_cb' => 'custom_navwalker::fallback', 'walker' => new custom_navwalker()]); ?> </div> </div> <?php } ?> </div><!-- /.g --> <p class="footer-meta copyright"> <?php echo class_exists('theme_user_code') ? theme_user_code::get_frontend_footer_code() : null; ?> </p> <?php } else { ?>
?> "><?php echo ___('Change my avatar'); ?> </legend> <!-- current avatar --> <div class="form-group"> <div class="control-label g-tablet-1-6"> <?php echo ___('Current avatar'); ?> </div> <div class="g-tablet-5-6"> <div class="current-avatar"> <?php echo theme_cache::get_avatar($current_user->ID, 100); ?> </div> </div> </div> <!-- new avatar --> <div class="form-group"> <div class="control-label g-tablet-1-6"> <?php echo ___('New avatar'); ?> </div> <div class="g-tablet-5-6"> <div class="row"> <div class="g-tablet-1-2"> <div id="cropper-container"></div>
function die_json_error_msg($id, $message) { die(json_encode(array('error' => sprintf(___('"%1$s" (ID %2$s) failed to resize. The error message was: %3$s'), theme_cache::get_the_title($id), $id, $message)))); }
public static function frontend_seajs_use() { if (!theme_cache::is_singular()) { return false; } ?> seajs.use('<?php echo self::$iden; ?> ',function(m){ m.init(); }); <?php }
public static function frontend_seajs_use() { if (!self::is_enabled() || !theme_cache::is_singular()) { return false; } ?> seajs.use('<?php echo self::$iden; ?> ',function(m){ m.config.lang.M01 = '<?php echo ___('Table of content'); ?> '; m.config.lang.M02 = '<?php echo ___('[TOC]'); ?> '; m.init(); }); <?php }
public static function frontend_seajs_use() { if (!theme_cache::is_singular('post')) { return false; } ?> seajs.use('<?php echo __CLASS__; ?> ',function(m){ m.init(); }); <?php }
public static function frontend_js_config(array $config) { if (!theme_cache::is_singular('post')) { return $config; } $config[__CLASS__] = ['process_url' => theme_features::get_process_url(['action' => __CLASS__, 'type' => 'incr'])]; return $config; }
public static function can_show() { static $cache = null; if ($cache === null) { global $post; $cache = theme_cache::is_singular() && !post_password_required() && comments_open(); } return $cache; }