Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.70 KB | None | 0 0
  1. ?php
  2.  
  3. if (function_exists('register_sidebar')) {
  4. register_sidebar(array(
  5. 'name' => 'Side Bar',
  6. 'before_widget' => '<div class="box box-%2$s">',
  7. 'after_widget' => '</div></div>',
  8. 'before_title' => '<h2><span>',
  9. 'after_title' => '</span></h2><div class="interior">',
  10. ));
  11. }
  12.  
  13. $themename = "Matatag";
  14. $shortname = "matatag";
  15.  
  16. function themefunction_add_admin() {
  17. global $themename, $shortname;
  18.  
  19. if ( $_GET['page'] == basename(__FILE__) ) {
  20. if ( 'save' == $_REQUEST['action'] ) {
  21.  
  22. update_option($shortname . '_twitter_username', $_REQUEST[$shortname . '_twitter_username']);
  23. update_option($shortname . '_feedburner_id', $_REQUEST[$shortname . '_feedburner_id']);
  24. update_option($shortname . '_latestnews_slug', $_REQUEST[$shortname . '_latestnews_slug']);
  25. update_option($shortname . '_ad_728', stripslashes($_REQUEST[$shortname . '_ad_728']));
  26. update_option($shortname . '_ad_468', stripslashes($_REQUEST[$shortname . '_ad_468']));
  27. update_option($shortname . '_ad_250', stripslashes($_REQUEST[$shortname . '_ad_250']));
  28. update_option($shortname . '_banner_img_url', $_REQUEST[$shortname . '_banner_img_url']);
  29. update_option($shortname . '_banner_web_url', $_REQUEST[$shortname . '_banner_web_url']);
  30. update_option($shortname . '_sqbtn_1_img_url', $_REQUEST[$shortname . '_sqbtn_1_img_url']);
  31. update_option($shortname . '_sqbtn_1_web_url', $_REQUEST[$shortname . '_sqbtn_1_web_url']);
  32. update_option($shortname . '_sqbtn_2_img_url', $_REQUEST[$shortname . '_sqbtn_2_img_url']);
  33. update_option($shortname . '_sqbtn_2_web_url', $_REQUEST[$shortname . '_sqbtn_2_web_url']);
  34. update_option($shortname . '_sqbtn_3_img_url', $_REQUEST[$shortname . '_sqbtn_3_img_url']);
  35. update_option($shortname . '_sqbtn_3_web_url', $_REQUEST[$shortname . '_sqbtn_3_web_url']);
  36. update_option($shortname . '_sqbtn_4_img_url', $_REQUEST[$shortname . '_sqbtn_4_img_url']);
  37. update_option($shortname . '_sqbtn_4_web_url', $_REQUEST[$shortname . '_sqbtn_4_web_url']);
  38.  
  39. header("Location: themes.php?page=functions.php&saved=true");
  40. die;
  41.  
  42. } else if ( 'reset' == $_REQUEST['action'] ) {
  43.  
  44. delete_option( $value['id'] );
  45.  
  46. header("Location: themes.php?page=functions.php&reset=true");
  47. die;
  48. }
  49. }
  50.  
  51. add_theme_page($themename." Options", "$themename Options", 'edit_themes', basename(__FILE__), 'themefunction_admin');
  52. }
  53.  
  54. function themefunction_admin() {
  55.  
  56. global $themename, $shortname, $options;
  57.  
  58. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  59. if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  60.  
  61. require get_theme_root() . '/' . $shortname . '/options/userinterface.php';
  62. }
  63.  
  64. add_action('admin_menu', 'themefunction_add_admin');
  65.  
  66. function themefunction_cleanup($str) {
  67. global $akpc, $post;
  68. $show = true;
  69. $show = apply_filters('akpc_display_popularity', $show, $post);
  70. if (is_feed() || is_admin_page() || get_post_meta($post->ID, 'hide_popularity', true) || !$show) {
  71. return $str;
  72. }
  73. return $str.'';
  74. }
  75.  
  76. function themefunction_list_bookmarks() {
  77. $array = array();
  78. $array[] = 'class=box box-partners';
  79. $array[] = 'category_before=<div class="%class">';
  80. $array[] = 'category_after=</div></div>';
  81. $array[] = 'title_before=<h2>';
  82. $array[] = 'title_after=</h2><div class="interior">';
  83. $array[] = 'categorize=0';
  84. $array[] = 'title_li=Our Partners';
  85. wp_list_bookmarks(implode('&',$array));
  86. }
  87.  
  88. function themefunction_recentpost() {
  89. echo '<ul>';
  90. wp_get_archives('type=postbypost&limit=5&format=custom&before=<li><span>&after=</span></li>');
  91. echo '</ul>';
  92. }
  93.  
  94. function themefunction_recentcomments() {
  95. echo '<ul>';
  96. themefunction_format_recentcomments();
  97. echo '</ul>';
  98. }
  99.  
  100. function themefunction_get_categories($cat_id) {
  101. if ('' != get_the_category_by_ID($cat_id)) {
  102. echo '<li>';
  103. echo '<a href="' . get_category_link($cat_id) . '">' . get_the_category_by_ID($cat_id) . '</a>';
  104. if ('' != (get_category_children($cat_id))) {
  105. echo '<ul>';
  106. wp_list_categories('hide_empty=0&title_li=&child_of=' . $cat_id);
  107. echo '</ul>';
  108. }
  109. echo '</li>';
  110. }
  111. }
  112.  
  113. function themefunction_format_recentcomments(
  114. $no_comments = 5,
  115. $show_pass_post = false,
  116. $title_length = 35, // shortens the title if it is longer than this number of chars
  117. $author_length = 15, // shortens the author if it is longer than this number of chars
  118. $wordwrap_length = 35, // adds a blank if word is longer than this number of chars
  119. $comment_length = 80,
  120. $type = 'all', // Comments, trackbacks, or both?
  121. $format = '<li><a href="%permalink%" title="%title%">%title%</a><br />%excerpt% <cite>%author_name%</cite></li>',
  122. $date_format = 'd.m.y, H:i',
  123. $none_found = '<li>No comments.</li>', // None found
  124. $type_text_pingback = 'Pingback by',
  125. $type_text_trackback = 'Trackback by',
  126. $type_text_comment = 'By'
  127.  
  128. ) {
  129.  
  130. //Language...
  131. $mwlang_anonymous = 'Anonymous'; // Anonymous
  132. $mwlang_authorurl_title_before = 'Webseite von ‹';
  133. $mwlang_authorurl_title_after = '› besuchen';
  134.  
  135. global $wpdb;
  136.  
  137. $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, comment_date, post_title, comment_type
  138. FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID
  139. WHERE post_status IN ('publish','static')";
  140.  
  141. switch($type) {
  142. case 'all':
  143. // add nothing
  144. break;
  145. case 'comment_only':
  146. //
  147. $request .= "AND $wpdb->comments.comment_type='' ";
  148. break;
  149. case 'trackback_only':
  150. $request .= "AND ( $wpdb->comments.comment_type='trackback' OR $wpdb->comments.comment_type='pingback' ) ";
  151. break;
  152. default:
  153. //
  154. break;
  155.  
  156. }
  157.  
  158. if (!$show_pass_post) $request .= "AND post_password ='' ";
  159.  
  160. $request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments";
  161.  
  162. $comments = $wpdb->get_results($request);
  163. $output = '';
  164. if ($comments) {
  165. foreach ($comments as $comment) {
  166.  
  167. // Permalink to post/comment
  168. $loop_res['permalink'] = get_permalink($comment->ID). '#comment-' . $comment->comment_ID;
  169.  
  170. // Title of the post
  171. $loop_res['post_title'] = stripslashes($comment->post_title);
  172. $loop_res['post_title'] = wordwrap($loop_res['post_title'], $wordwrap_length, ' ' , 1);
  173.  
  174. if (strlen($loop_res['post_title']) >= $title_length) {
  175. $loop_res['post_title'] = substr($loop_res['post_title'], 0, $title_length) . '…';
  176. }
  177.  
  178. // Author's name only
  179. $loop_res['author_name'] = stripslashes($comment->comment_author);
  180. $loop_res['author_name'] = wordwrap($loop_res['author_name'], $wordwrap_length, ' ' , 1);
  181.  
  182. if ($loop_res['author_name'] == '') $loop_res['author_name'] = $mwlang_anonymous;
  183. if (strlen($loop_res['author_name']) >= $author_length) {
  184. $loop_res['author_name'] = substr($loop_res['author_name'], 0, $author_length) . '…';
  185. }
  186.  
  187. // Full author (link, name)
  188. $author_url = $comment->comment_author_url;
  189. if (empty($author_url)) {
  190. $loop_res['author_full'] = $loop_res['author_name'];
  191. } else {
  192. $loop_res['author_full'] = '<a href="' . $author_url . '" title="' . $mwlang_authorurl_title_before . $loop_res['author_name'] . $mwlang_authorurl_title_after . '">' . $loop_res['author_name'] . '</a>';
  193. }
  194.  
  195. // Comment excerpt
  196. $comment_excerpt = strip_tags($comment->comment_content);
  197. $comment_excerpt = stripslashes($comment_excerpt);
  198. if (strlen($comment_excerpt) >= $comment_length) {
  199. $comment_excerpt = substr($comment_excerpt, 0, $comment_length) . '...';
  200. }
  201.  
  202. // Comment type
  203. if ( $comment->comment_type == 'pingback' ) {
  204. $loop_res['comment_type'] = $type_text_pingback;
  205. } elseif ( $comment->comment_type == 'trackback' ) {
  206. $loop_res['comment_type'] = $type_text_trackback;
  207. } else {
  208. $loop_res['comment_type'] = $type_text_comment;
  209. }
  210.  
  211. // Date of comment
  212. $loop_res['comment_date'] = mysql2date($date_format, $comment->comment_date);
  213.  
  214. // Output element
  215. $element_loop = str_replace('%permalink%', $loop_res['permalink'], $format);
  216. $element_loop = str_replace('%title%', $loop_res['post_title'], $element_loop);
  217. $element_loop = str_replace('%author_name%', $loop_res['author_name'], $element_loop);
  218. $element_loop = str_replace('%author_full%', $loop_res['author_full'], $element_loop);
  219. $element_loop = str_replace('%date%', $loop_res['comment_date'], $element_loop);
  220. $element_loop = str_replace('%type%', $loop_res['comment_type'], $element_loop);
  221. $element_loop = str_replace('%excerpt%', $comment_excerpt, $element_loop);
  222.  
  223. $output .= $element_loop . "\n";
  224.  
  225. } //foreach
  226.  
  227. $output = convert_smilies($output);
  228.  
  229. } else {
  230. $output .= $none_found;
  231. }
  232.  
  233. echo $output;
  234. }
  235.  
  236. function themefunction_list_pages_flat($args = '') {
  237. $defaults = array(
  238. 'depth' => 0, 'show_date' => '',
  239. 'date_format' => get_option('date_format'),
  240. 'child_of' => 0, 'exclude' => '',
  241. 'title_li' => __('Pages'), 'echo' => 1,
  242. 'authors' => '', 'sort_column' => 'menu_order, post_title'
  243. );
  244.  
  245. $r = wp_parse_args( $args, $defaults );
  246. extract( $r, EXTR_SKIP );
  247.  
  248. $output = '';
  249. $current_page = 0;
  250.  
  251. // sanitize, mostly to keep spaces out
  252. $r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
  253.  
  254. // Allow plugins to filter an array of excluded pages
  255. $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
  256.  
  257. // Query pages.
  258. $r['hierarchical'] = 0;
  259. $pages = get_pages($r);
  260.  
  261. if ( !empty($pages) ) {
  262. if ( $r['title_li'] )
  263. $output .= '<li class="pagenav">' . $r['title_li'] . '<li>';
  264.  
  265. global $wp_query;
  266. if ( is_page() || $wp_query->is_posts_page )
  267. $current_page = $wp_query->get_queried_object_id();
  268. $output .= themefunction_walk_page_tree($pages, $r['depth'], $current_page, $r);
  269.  
  270. }
  271.  
  272. $output = apply_filters('themefunction_list_pages_flat', $output);
  273.  
  274. if ( $r['echo'] )
  275. echo $output;
  276. else
  277. return $output;
  278. }
  279.  
  280. function themefunction_walk_page_tree() {
  281. $tfwalker = new TF_Walker_Page;
  282. $args = func_get_args();
  283. return call_user_func_array(array(&$tfwalker, 'walk'), $args);
  284. }
  285.  
  286. class TF_Walker_Page extends Walker {
  287. var $tree_type = 'page';
  288. var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
  289.  
  290. function start_lvl($output, $depth) {
  291. $indent = str_repeat("\t", $depth);
  292. $output .= "\n$indent\n";
  293. return $output;
  294. }
  295.  
  296. function end_lvl($output, $depth) {
  297. $indent = str_repeat("\t", $depth);
  298. $output .= "$indent\n";
  299. return $output;
  300. }
  301.  
  302. function start_el($output, $page, $depth, $current_page, $args) {
  303. if ( $depth )
  304. $indent = str_repeat("\t", $depth);
  305. else
  306. $indent = '';
  307.  
  308. extract($args, EXTR_SKIP);
  309. $css_class = 'page_item page-item-'.$page->ID;
  310. if ( !empty($current_page) ) {
  311. $_current_page = get_page( $current_page );
  312. if ( in_array($page->ID, (array) $_current_page->ancestors) )
  313. $css_class .= ' current_page_ancestor';
  314. if ( $page->ID == $current_page )
  315. $css_class .= ' current_page_item';
  316. elseif ( $_current_page && $page->ID == $_current_page->post_parent )
  317. $css_class .= ' current_page_parent';
  318. }
  319.  
  320. $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '"><span>' . apply_filters('the_title', $page->post_title) . '</span></a></li>';
  321.  
  322. if ( !empty($show_date) ) {
  323. if ( 'modified' == $show_date )
  324. $time = $page->post_modified;
  325. else
  326. $time = $page->post_date;
  327.  
  328. $output .= " " . mysql2date($date_format, $time);
  329. }
  330.  
  331. return $output;
  332. }
  333.  
  334. function end_el($output, $page, $depth) {
  335. $output .= "\n";
  336.  
  337. return $output;
  338. }
  339.  
  340. }
  341. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement