PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/themes/wptouch/wpcom.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 256 lines | 210 code | 42 blank | 4 comment | 49 complexity | 9765b0872d24f8c3a59848639b0cba9b MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * This file contains some variable and function definitions take from
  4. * the wptouch plugin, so that it can work as a standalone theme on WordPress.com
  5. */
  6. global $wptouch_defaults;
  7. $wptouch_defaults = array(
  8. 'header-title' => get_bloginfo('name'),
  9. 'main_title' => 'Default.png',
  10. 'enable-post-excerpts' => true,
  11. 'enable-page-coms' => true,
  12. 'enable-cats-button' => true,
  13. 'enable-tags-button' => true,
  14. 'enable-login-button' => false,
  15. 'enable-ajax-comments' => true,
  16. 'enable-gravatars' => true,
  17. 'enable-main-home' => true,
  18. 'enable-main-rss' => true,
  19. 'enable-main-name' => true,
  20. 'enable-main-tags' => true,
  21. 'enable-main-categories' => true,
  22. 'enable-main-email' => true,
  23. 'header-background-color' => '000000',
  24. 'header-border-color' => '333333',
  25. 'header-text-color' => 'eeeeee',
  26. 'link-color' => '006bb3',
  27. 'style-text-size' => '',
  28. 'style-text-justify' => 'full-justified',
  29. 'style-background' => 'classic-wptouch-bg',
  30. 'enable-regular-default' => false,
  31. 'excluded-cat-ids' => '',
  32. 'home-page' => 0,
  33. 'enable-exclusive' => false,
  34. 'sort-order' => 'name',
  35. 'adsense-id' => '',
  36. 'statistics' => '',
  37. 'adsense-channel' => ''
  38. );
  39. function wptouch_ajax_url() {
  40. return get_bloginfo( 'url' ) . '/index.php?wptouch=ajax-comments-handler';
  41. }
  42. function wptouch_dir() {
  43. return dirname( __FILE__ );
  44. }
  45. function bnc_get_header_title() {
  46. $v = bnc_wp_touch_get_menu_pages();
  47. return $v['header-title'];
  48. }
  49. function bnc_get_header_background() {
  50. $v = bnc_wp_touch_get_menu_pages();
  51. return $v['header-background-color'];
  52. }
  53. function bnc_get_header_border_color() {
  54. $v = bnc_wp_touch_get_menu_pages();
  55. return $v['header-border-color'];
  56. }
  57. function bnc_get_header_color() {
  58. $v = bnc_wp_touch_get_menu_pages();
  59. return $v['header-text-color'];
  60. }
  61. function bnc_get_link_color() {
  62. $v = bnc_wp_touch_get_menu_pages();
  63. return $v['link-color'];
  64. }
  65. function bnc_wp_touch_get_menu_pages() {
  66. $v = get_option('bnc_iphone_pages');
  67. if (!$v) {
  68. $v = array();
  69. }
  70. if (!is_array($v)) {
  71. $v = unserialize($v);
  72. }
  73. bnc_validate_wptouch_settings( $v );
  74. return $v;
  75. }
  76. function bnc_validate_wptouch_settings( &$settings ) {
  77. global $wptouch_defaults;
  78. foreach ( $wptouch_defaults as $key => $value ) {
  79. if ( !isset( $settings[$key] ) ) {
  80. $settings[$key] = $value;
  81. }
  82. }
  83. }
  84. function bnc_get_title_image() {
  85. $ids = bnc_wp_touch_get_menu_pages();
  86. $title_image = $ids['main_title'];
  87. if ( file_exists( wptouch_dir() . '/images/icon-pool/' . $title_image ) ) {
  88. $image = get_stylesheet_directory_uri() . '/images/icon-pool/' . $title_image;
  89. }
  90. return $image;
  91. }
  92. function bnc_wptouch_is_exclusive() {
  93. $settings = bnc_wptouch_get_settings();
  94. return $settings['enable-exclusive'];
  95. }
  96. function bnc_wptouch_get_settings() {
  97. return bnc_wp_touch_get_menu_pages();
  98. }
  99. function bnc_get_selected_home_page() {
  100. $v = bnc_wp_touch_get_menu_pages();
  101. return $v['home-page'];
  102. }
  103. function wptouch_get_stats() {
  104. $options = bnc_wp_touch_get_menu_pages();
  105. if (isset($options['statistics'])) {
  106. echo stripslashes($options['statistics']);
  107. }
  108. }
  109. function wptouch_excluded_cats() {
  110. $settings = bnc_wptouch_get_settings();
  111. return stripslashes($settings['excluded-cat-ids']);
  112. }
  113. function bnc_excerpt_enabled() {
  114. $ids = bnc_wp_touch_get_menu_pages();
  115. return $ids['enable-post-excerpts'];
  116. }
  117. function bnc_is_page_coms_enabled() {
  118. $ids = bnc_wp_touch_get_menu_pages();
  119. return $ids['enable-page-coms'];
  120. }
  121. function bnc_is_cats_button_enabled() {
  122. $ids = bnc_wp_touch_get_menu_pages();
  123. return $ids['enable-cats-button'];
  124. }
  125. function bnc_is_tags_button_enabled() {
  126. $ids = bnc_wp_touch_get_menu_pages();
  127. return $ids['enable-tags-button'];
  128. }
  129. function bnc_is_login_button_enabled() {
  130. $ids = bnc_wp_touch_get_menu_pages();
  131. return $ids['enable-login-button'];
  132. }
  133. function bnc_is_gravatars_enabled() {
  134. $ids = bnc_wp_touch_get_menu_pages();
  135. return $ids['enable-gravatars'];
  136. }
  137. function bnc_is_ajax_coms_enabled() {
  138. $ids = bnc_wp_touch_get_menu_pages();
  139. return $ids['enable-ajax-comments'];
  140. }
  141. function bnc_show_author() {
  142. $ids = bnc_wp_touch_get_menu_pages();
  143. return $ids['enable-main-name'];
  144. }
  145. function bnc_show_tags() {
  146. $ids = bnc_wp_touch_get_menu_pages();
  147. return $ids['enable-main-tags'];
  148. }
  149. function bnc_show_categories() {
  150. $ids = bnc_wp_touch_get_menu_pages();
  151. return $ids['enable-main-categories'];
  152. }
  153. function bnc_is_home_enabled() {
  154. $ids = bnc_wp_touch_get_menu_pages();
  155. return $ids['enable-main-home'];
  156. }
  157. function bnc_is_rss_enabled() {
  158. $ids = bnc_wp_touch_get_menu_pages();
  159. return $ids['enable-main-rss'];
  160. }
  161. function bnc_is_email_enabled() {
  162. $ids = bnc_wp_touch_get_menu_pages();
  163. return $ids['enable-main-email'];
  164. }
  165. function bnc_wp_touch_get_pages() {
  166. global $table_prefix;
  167. global $wpdb;
  168. $ids = bnc_wp_touch_get_menu_pages();
  169. $a = array();
  170. $keys = array();
  171. foreach ($ids as $k => $v) {
  172. if ($k == 'main_title' || $k == 'enable-post-excerpts' || $k == 'enable-page-coms' ||
  173. $k == 'enable-cats-button' || $k == 'enable-tags-button' || $k == 'enable-login-button' ||
  174. $k == 'enable-gravatars' || $k == 'enable-ajax-comments' || $k == 'enable-main-home' ||
  175. $k == 'enable-main-rss' || $k == 'enable-main-email' || $k == 'enable-main-name' ||
  176. $k == 'enable-main-tags' || $k == 'enable-main-categories' ||
  177. $k == 'enable-prowl-comments-button' || $k == 'enable-prowl-users-button' ||
  178. $k == 'enable-prowl-message-button') {
  179. } else {
  180. if (is_numeric($k)) {
  181. $keys[] = $k;
  182. }
  183. }
  184. }
  185. $menu_order = array();
  186. $results = false;
  187. if ( count( $keys ) > 0 ) {
  188. $query = "select * from {$table_prefix}posts where ID in (" . implode(',', $keys) . ") and post_status = 'publish' order by post_title asc";
  189. $results = $wpdb->get_results( $query, ARRAY_A );
  190. }
  191. if ( $results ) {
  192. foreach ( $results as $row ) {
  193. $row['icon'] = $ids[$row['ID']];
  194. $a[$row['ID']] = $row;
  195. if (isset($menu_order[$row['menu_order']])) {
  196. $menu_order[$row['menu_order']*100 + $inc] = $row;
  197. } else {
  198. $menu_order[$row['menu_order']*100] = $row;
  199. }
  200. $inc = $inc + 1;
  201. }
  202. }
  203. if (isset($ids['sort-order']) && $ids['sort-order'] == 'page') {
  204. asort($menu_order);
  205. return $menu_order;
  206. } else {
  207. return $a;
  208. }
  209. }
  210. function wptouch_footer_credits() {
  211. printf( __( 'Theme: %1$s by %2$s.', 'wptouch' ), 'WPtouch', '<a href="http://www.bravenewcode.com/wptouch/" rel="designer">BraveNewCode</a>' );
  212. echo '<br /><a href="http://wordpress.com/" rel="generator">Get a free blog at WordPress.com</a>';
  213. }
  214. add_action( 'wp_footer', 'wptouch_footer_credits', 5 );