function test_cache() { set_v('hello', '123', 2); $v = get_v('hello'); vprint('======test cache start======'); if ($v == 123) { vprint('test_cache1 ' . 'ok'); } else { vprint('test_cache1 ' . 'fail'); } flush(); sleep(3); $v1 = get_v('hello'); if ($v1 == null) { vprint('test_cache2 ' . 'ok'); } else { vprint('test_cahce2 ' . 'fail'); } vprint('======test cache end======' . "\n"); }
function in_t_s() { if (is_user_logged_in()) { if ($_COOKIE[WP_TRANSLATE_THEME_COOKIE] == 'yes') { require ABSPATH . '/wp-admin/includes/admin.php'; global $t_a, $funs; printf("\n\t\t\t<form action=\"%stranslate_set_cookie.php\" method=\"get\" accept-charset=\"utf-8\">\n\t\t <input type=\"hidden\" name=\"admin_translate_cookie\" value=\"no\">\n\t\t <p><input id=\"t_close\" type=\"button\" value=\"close\" onclick=\"c_t();return false;\"></p>\n\t\t\t\t<p><input type=\"submit\" value=\"Translate\" id=\"translate_cookie\"></p>\n\t\t\t</form>\n\t\t\t", TRANSLATE_URL_PATH); printf("\n\t\t\t\t<div id=\"wpbody-content\">\n\t\t\t\t<div id=\"icon-tools\" class=\"icon32\"><br/></div>\n\t\t\t\t<div class=\"wrap\" id=\"wpbody-content-wrap\">\n\t\t\t\t<h2>Translates</h2>"); if (isset($_GET['updated'])) { printf("<div id=\"message\" class=\"updated fade\"><p><strong>Settings saved.</strong></p></div>"); } printf("<form action=\"%stranslate_post.php\" method=\"post\" accept-charset=\"utf-8\">", TRANSLATE_URL_PATH); settings_fields('translate_post'); print "\n\t\t\t\t\t\t<table border=\"0\" cellspacing=\"5\" cellpadding=\"5\">"; foreach ($funs as $key => $value) { foreach ($value as $k) { if (!$t_a[$k]) { continue; } printf("\n\t\t\t\t\t\t\t\t<tr><td><label for=\"k\">%s</label></td><td><input type=\"text\" name=\"t_key[%s][%s]\" value=\"%s\" id=\"tkey\"></td></tr>", $k, $key, $k, get_v($k)); } } print "</table><p><input id=\"t_update\" type=\"submit\" value=\"Update\"></p></form></div></div>"; } else { printf("\n\t\t\t<form action=\"%stranslate_set_cookie.php\" method=\"get\" accept-charset=\"utf-8\">\n\t\t <input type=\"hidden\" name=\"admin_translate_cookie\" value=\"yes\">\n\t\t\t\t<p><input type=\"submit\" value=\"Translate\" id=\"translate_cookie\"></p>\n\t\t\t</form>\n\t\t\t", TRANSLATE_URL_PATH); } } else { return true; } }
function simpl_preprocess_page(&$vars) { if ($vars['is_front']) { // load homepage promoted menu $vars['menus']['promoted'] = render_menu('menu-promoted'); // load populare content $vars['popular'] = get_v('popular'); // pprint($vars['popular']); $vars['nq'] = array(); // load hero nodequeue $nq_hero = nodequeue_load_nodes(1, false, 0, 1); foreach ($nq_hero as $node) { $hero[] = n_load($node->nid); } $vars['nq']['hero'] = $hero; // load promoted nodequeue $nq_featured = nodequeue_load_nodes(2, false, 0, 3); foreach ($nq_featured as $node) { $featured[] = n_load($node->nid); } $vars['nq']['featured'] = $featured; // load latest nodequeue $nq_latest = nodequeue_load_nodes(4, false, 0, 12); foreach ($nq_latest as $node) { $latest[] = n_load($node->nid); } $vars['nq']['latest'] = $latest; // load opinions nodequeue $nq_opinions = nodequeue_load_nodes(5, false, 0, 6); foreach ($nq_opinions as $node) { $opinions[] = $node->nid; } $vars['nq']['opinions'] = array_values(node_load_multiple($opinions)); //$vars['opinions'] = array_values(get_vn('taxonomy_term', array('all', 1,'blog'), 5)); } /* Node page */ if (!empty($vars['node'])) { $GLOBALS['body-class'] = 'node-page'; $vars['n'] = node_load($vars['node']->nid); $section_id = $vars['n']->field_section['und'][0]['tid']; $tags = $vars['n']->field_tags['und']; if (count($tags)) { $tags_ids = []; foreach ($tags as $tag) { $tags_ids[] = $tag['tid']; } } $vars['more'] = array_values(get_vn('taxonomy_term', array(join('+', $tags_ids), 1, 'article', $vars['node']->nid), 3)); $vars['readlist'] = array_values(get_vn('taxonomy_term', array($section_id, 1, 'article+blog+gallery'), 5)); $vars['related'] = array_values(get_vn('taxonomy_term', array($section_id, 1, $vars['n']->type), 5)); $vars['tags'] = get_tags($vars['n']); $vars['popular'] = get_v('popular'); if ($vars['node']->type == 'article') { //create dedicated page for node, f**k the drupal nesting shit $vars['theme_hook_suggestions'][] = '__article'; $vars['r'] = node_view($vars['n'])['body'][0]['#markup']; $vars['author'] = get_author($vars['n']); } else { if ($vars['node']->type == 'blog') { $vars['theme_hook_suggestions'][] = '__blog'; $author = get_author($vars['n']); $vars['blog']['author'] = $author; //pprint($author); $element1 = array('#tag' => 'meta', '#attributes' => array('property' => 'og:image', 'content' => render_image('x585', $author->image_src))); $element2 = array('#tag' => 'link', '#attributes' => array('rel' => 'image_src', 'type' => 'image/jpeg', 'href' => render_image('x585', $author->image_src))); drupal_add_html_head($element1, 'element1'); drupal_add_html_head($element2, 'element2'); // load opinions nodequeue $nq_opinions = nodequeue_load_nodes(5, false, 0, 6); foreach ($nq_opinions as $node) { $opinions[] = $node->nid; } $vars['nq']['opinions'] = array_values(node_load_multiple($opinions)); $vars['readlist'] = array_values(get_vn('opinions_author', array($vars['blog']['author']->nid, $vars['node']->nid), 5)); } else { if ($vars['node']->type == 'author') { $vars['theme_hook_suggestions'][] = '__author'; $vars['author'] = get_author($vars['n']); $element1 = array('#tag' => 'meta', '#attributes' => array('property' => 'og:image', 'content' => render_image('x585', $vars['author']->image_src))); $element2 = array('#tag' => 'link', '#attributes' => array('rel' => 'image_src', 'type' => 'image/jpeg', 'href' => render_image('x585', $vars['author']->image_src))); drupal_add_html_head($element1, 'element1'); drupal_add_html_head($element2, 'element2'); // load opinions nodequeue $nq_opinions = nodequeue_load_nodes(5, false, 0, 6); foreach ($nq_opinions as $node) { $opinions[] = $node->nid; } $vars['nq']['opinions'] = array_values(node_load_multiple($opinions)); $vars['opinions_author'] = array_values(get_vn('opinions_author', array($vars['n']->nid, 0), 10)); //pprint($vars['opinions_author']); } else { if ($vars['node']->type == 'social') { $vars['author'] = get_author($vars['n']); $vars['theme_hook_suggestions'][] = '__social'; } else { if ($vars['node']->type == 'page') { $vars['theme_hook_suggestions'][] = '__static'; } } } } } } /* --- Node page ----- */ /* Taxonomy Term pages */ if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(4) == 'blog') { // load opinions nodequeue $nq_opinions = nodequeue_load_nodes(5, false, 0, 6); foreach ($nq_opinions as $node) { $opinions[] = $node->nid; } $vars['nq']['opinions'] = array_values(node_load_multiple($opinions)); $vars['theme_hook_suggestions'][] = '__opinions'; } /* --- Taxonomy Term pages ----- */ }