Advertisement
Guest User

Untitled

a guest
May 6th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.84 KB | None | 0 0
  1. <?php
  2.  
  3. @ini_set( 'upload_max_size' , '64M' );
  4. @ini_set( 'post_max_size', '64M');
  5. @ini_set( 'max_execution_time', '300' );
  6.  
  7.  
  8. // Navigation
  9.  
  10. register_nav_menus( array(
  11. 'main' => __( 'Primary Navigation' ),
  12. 'footer-menu' => __( 'Footer Navigation' ),
  13. ) );
  14.  
  15. // Register scripts
  16. function my_scripts_method() {
  17. wp_deregister_script( 'jquery' );
  18. wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
  19. wp_enqueue_script( 'jquery' );
  20. }
  21.  
  22. add_action('wp_enqueue_scripts', 'my_scripts_method');
  23.  
  24.  
  25.  
  26. // Add first_item and last_item class to last li in wp_nav_menu lists
  27.  
  28. function add_first_and_last($output) {
  29. $output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
  30. $output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
  31. return $output;
  32. }
  33. add_filter('wp_nav_menu', 'add_first_and_last');
  34.  
  35.  
  36.  
  37. //register sidebars
  38. if ( function_exists('register_sidebar') )
  39. register_sidebar(array('name' => 'header-search',
  40. ));
  41. register_sidebar(array('name' => 'twitter',
  42. ));
  43. //register_sidebar(array('name' => 'footer-external-news',
  44. //));
  45. register_sidebar(array('name' => 'page',
  46. ));
  47. //register_sidebar(array('name' => 'news',
  48. //));
  49. //register_sidebar(array('name' => 'events',
  50. //));
  51. //register_sidebar(array('name' => 'resources',
  52. //));
  53.  
  54.  
  55. //register custom posts
  56.  
  57. register_post_type( 'blocks',
  58. array(
  59. 'label' => __( 'Homepage Blocks' ),
  60. 'singular_label' => __( 'Homepage Block' ),
  61. '_builtin' => false, // It's a custom post type, not built in!
  62. 'public' => true,
  63. 'menu_position' => 5,
  64. 'query_var' => true,
  65. 'hierarchical' => true,
  66. 'attributes' => true,
  67. 'supports' => array('title'),
  68. 'rewrite' => array('slug'=>'block'),
  69. )
  70. );
  71. register_post_type( 'sponsors',
  72. array(
  73. 'label' => __( 'Sponsors' ),
  74. 'singular_label' => __( 'Sponsor' ),
  75. '_builtin' => false, // It's a custom post type, not built in!
  76. 'public' => true,
  77. 'menu_position' => 6,
  78. 'query_var' => true,
  79. 'hierarchical' => true,
  80. 'attributes' => true,
  81. 'supports' => array('title', 'editor'),
  82. 'rewrite' => array('slug'=>'sponsors'),
  83. )
  84. );
  85. register_post_type( 'where_to',
  86. array(
  87. 'label' => __( 'Where to' ),
  88. 'singular_label' => __( 'Where to' ),
  89. '_builtin' => false, // It's a custom post type, not built in!
  90. 'public' => true,
  91. 'menu_position' => 5,
  92. 'query_var' => true,
  93. 'hierarchical' => true,
  94. 'attributes' => true,
  95. 'supports' => array('title', 'editor', 'thumbnail'),
  96. 'rewrite' => array('slug'=>'where_to'),
  97. )
  98. );
  99. register_post_type( 'whats_going_on',
  100. array(
  101. 'label' => __( 'What is going on' ),
  102. 'singular_label' => __( 'What is going on' ),
  103. '_builtin' => false, // It's a custom post type, not built in!
  104. 'public' => true,
  105. 'menu_position' => 5,
  106. 'query_var' => true,
  107. 'hierarchical' => true,
  108. 'attributes' => true,
  109. 'supports' => array('title', 'editor', 'thumbnail'),
  110. 'rewrite' => array('slug'=>'whats_going_on'),
  111. )
  112. );
  113.  
  114.  
  115. // Custom Meta Boxes
  116. //// Setup Meta Box Data
  117. global $prefix;
  118. $prefix = 'cf_';
  119. $meta_boxes = array();
  120.  
  121. // For Home Blocks
  122. $meta_boxes[] = array(
  123. 'id' => 'block_meta_box_title_location',
  124. 'title' => 'Title and Location',
  125. 'pages' => array('blocks'), // post type
  126. 'context' => 'normal',
  127. 'priority' => 'high',
  128. 'show_names' => true, // Show field names left of input
  129. 'fields' => array(
  130. array(
  131. 'name' => 'Title',
  132. 'id' => 'blockTitle',
  133. 'type' => 'text'
  134. ),
  135. array(
  136. 'name' => 'Subtitle',
  137. 'id' => 'blockSubTitle',
  138. 'type' => 'text'
  139. ),
  140. array(
  141. 'name' => 'What is the position of this block on the Homepage?',
  142. 'id' => 'blockLocation',
  143. 'type' => 'select',
  144. 'options' => array(
  145. array('name' => '', 'value' => ''),
  146. array('name' => 'Welcome', 'value' => 'welcome'),
  147. array('name' => 'Page Link x4', 'value' => 'pageLinkX4'),
  148. array('name' => 'Page Link x3', 'value' => 'pageLinkX3'),
  149. array('name' => 'Banner', 'value' => 'banner')
  150. )
  151. )
  152. )
  153. );
  154. $meta_boxes[] = array(
  155. 'id' => 'block_meta_box_content',
  156. 'title' => 'Content',
  157. 'pages' => array('blocks'), // post type
  158. 'context' => 'normal',
  159. 'priority' => 'high',
  160. 'show_names' => true, // Show field names left of input
  161. 'fields' => array(
  162. array(
  163. 'name' => 'Image',
  164. 'id' => 'blockImage',
  165. 'desc' => 'Which image do you want to use? Copy/Paste the image URL from the media Library here.',
  166. 'type' => 'text'
  167. ),
  168. array(
  169. 'name' => 'Image Alt Tag',
  170. 'id' => 'blockALT',
  171. 'desc' => 'For good SEO lable the image, try and use relevant keywords.',
  172. 'type' => 'text'
  173. ),
  174. array(
  175. 'name' => 'URL',
  176. 'id' => 'blockURL',
  177. 'desc' => 'When the user clicks on the links in this block, where do you want them to go?',
  178. 'type' => 'text'
  179. ),
  180. array(
  181. 'name' => 'Description',
  182. 'id' => 'blockText',
  183. 'type' => 'textarea'
  184. )
  185. )
  186. );
  187. // For Sponsors
  188. $meta_boxes[] = array(
  189. 'id' => 'block_meta_box_sponsors',
  190. 'title' => 'Sponsors',
  191. 'pages' => array('sponsors'), // post type
  192. 'context' => 'normal',
  193. 'priority' => 'high',
  194. 'show_names' => true, // Show field names left of input
  195. 'fields' => array(
  196. array(
  197. 'name' => 'Image',
  198. 'id' => 'sponsorImage',
  199. 'desc' => 'Which logo/image do you want to use? Copy/Paste the image URL from the media Library here.',
  200. 'type' => 'text'
  201. ),
  202. array(
  203. 'name' => 'Image Alt Tag',
  204. 'id' => 'sponsorALT',
  205. 'desc' => 'For good SEO lable the image, try and use relevant keywords.',
  206. 'type' => 'text'
  207. ),
  208. array(
  209. 'name' => 'URL',
  210. 'id' => 'sponsorURL',
  211. 'desc' => 'When the user clicks on the links in this block, where do you want them to go?',
  212. 'type' => 'text'
  213. )
  214. )
  215. );
  216. // For Whats going on
  217. $meta_boxes[] = array(
  218. 'id' => 'block_meta_box_whats_going_on_what',
  219. 'title' => 'Type',
  220. 'pages' => array('whats_going_on'), // post type
  221. 'context' => 'normal',
  222. 'priority' => 'high',
  223. 'show_names' => true, // Show field names left of input
  224. 'fields' => array(
  225. array(
  226. 'name' => 'Type',
  227. 'id' => 'block_meta_box_whats_going_on_type',
  228. 'type' => 'select',
  229. 'options' => array(
  230. array('name' => '', 'value' => ''),
  231. array('name' => 'Market', 'value' => 'Market'),
  232. array('name' => 'Demo', 'value' => 'Demo'),
  233. array('name' => 'Offer', 'value' => 'Offer')
  234. )
  235. )
  236. )
  237. );
  238. // For Where to
  239. $meta_boxes[] = array(
  240. 'id' => 'block_meta_box_where_to_what',
  241. 'title' => 'Where to',
  242. 'pages' => array('where_to'), // post type
  243. 'context' => 'normal',
  244. 'priority' => 'high',
  245. 'show_names' => true, // Show field names left of input
  246. 'fields' => array(
  247. array(
  248. 'name' => 'Type',
  249. 'id' => 'block_meta_box_where_to_type',
  250. 'type' => 'select',
  251. 'options' => array(
  252. array('name' => '', 'value' => ''),
  253. array('name' => 'Eat', 'value' => 'Eat'),
  254. array('name' => 'Stay', 'value' => 'Stay')
  255. )
  256. )
  257. )
  258. );
  259. $meta_boxes[] = array(
  260. 'id' => 'block_meta_box_where_to_details',
  261. 'title' => 'Details',
  262. 'pages' => array('where_to'), // post type
  263. 'context' => 'normal',
  264. 'priority' => 'high',
  265. 'show_names' => true, // Show field names left of input
  266. 'fields' => array(
  267. array(
  268. 'name' => 'Business Name',
  269. 'id' => 'where_to_name',
  270. 'type' => 'text'
  271. ),
  272. array(
  273. 'name' => 'Business Type',
  274. 'id' => 'where_to_type',
  275. 'desc' => 'What type of hotel/restuarant is it?',
  276. 'type' => 'text'
  277. ),
  278. array(
  279. 'name' => 'Business Location',
  280. 'id' => 'where_to_location',
  281. 'type' => 'text'
  282. ),
  283. array(
  284. 'name' => 'Business Address',
  285. 'id' => 'where_to_address',
  286. 'type' => 'textarea'
  287. ),
  288. array(
  289. 'name' => 'Business Phone',
  290. 'id' => 'where_to_phone',
  291. 'type' => 'text'
  292. ),
  293. array(
  294. 'name' => 'Business Web',
  295. 'id' => 'where_to_web',
  296. 'type' => 'text'
  297. ),
  298. array(
  299. 'name' => 'Business Email',
  300. 'id' => 'where_to_email',
  301. 'type' => 'text'
  302. ),
  303. )
  304. );
  305.  
  306. //-- Begin moving post editor to notes metabox ---------
  307. // Comment this out to disable
  308. $meta_boxes[] = array(
  309. 'id' => 'block_meta_box_where_to_desc',
  310. 'title' => 'Description',
  311. 'pages' => array('where_to'), // post type
  312. 'context' => 'normal',
  313. 'priority' => 'high',
  314. 'show_names' => false, // Show field names left of input
  315. 'fields' => array()
  316. );
  317. //-- Pause moving post editor
  318.  
  319. //-- Unpause moving post editor
  320. function crm_move_posteditor( $hook ) {
  321. if ( $hook == 'post.php' OR $hook == 'post-new.php' ) {
  322. wp_enqueue_script( 'jquery' );
  323. add_action('admin_print_footer_scripts','crm_move_posteditor_scripts');
  324. }
  325. }
  326. add_action( 'admin_enqueue_scripts', 'crm_move_posteditor', 10, 1 );
  327.  
  328. function crm_move_posteditor_scripts() {
  329. ?>
  330. <script type="text/javascript">
  331. jQuery('#postdiv, #postdivrich').prependTo('#block_meta_box_where_to_desc .inside');
  332. </script>
  333. <style type="text/css">
  334. #normal-sortables {margin-top: 20px;}
  335. #titlediv { margin-bottom: 0px; }
  336. #postdiv.postarea, #postdivrich.postarea { margin:0; }
  337. #post-status-info { line-height:1.4em; font-size:13px; }
  338. #custom_editor .inside { margin:2px 6px 6px 6px; }
  339. #ed_toolbar { display:none; }
  340. #postdiv #ed_toolbar, #postdivrich #ed_toolbar { display:block; }
  341. </style>
  342. <?php
  343. }
  344. //-- End moving post editor
  345.  
  346. // Create Meta Box
  347. include_once( '_/metabox/init.php' );
  348.  
  349.  
  350.  
  351.  
  352.  
  353. // Add ability to upload Adobe files (photoshop, etc)
  354. // MIME types found at http://www.webmaster-toolkit.com/mime-types.shtml
  355. function crm_add_upload_support( $mimes ) {
  356. $mimes['psd'] = 'application/psd';
  357. $mimes['eps'] = 'application/postscript';
  358. $mimes['ai'] = 'application/postscript';
  359. return $mimes;
  360. }
  361. add_filter( 'upload_mimes','crm_add_upload_support' );
  362.  
  363.  
  364. // important: note the priority of 99, the js needs to be placed after tinymce loads
  365. add_action('admin_print_footer_scripts','my_admin_print_footer_scripts',99);
  366. function my_admin_print_footer_scripts()
  367. {
  368. ?><script type="text/javascript">/* <![CDATA[ */
  369. jQuery(function($)
  370. {
  371. var i=1;
  372. $('.theEditor textarea').each(function(e)
  373. {
  374. var id = $(this).attr('id');
  375.  
  376. if (!id)
  377. {
  378. id = 'theEditor-' + i++;
  379. $(this).attr('id',id);
  380. }
  381.  
  382. tinyMCE.execCommand('mceAddControl', false, id);
  383.  
  384. });
  385. });
  386. /* ]]> */</script><?php
  387. }
  388.  
  389.  
  390. // Customise Admin
  391.  
  392.  
  393. //// Menu Order
  394.  
  395. function custom_menu_order($menu_ord) {
  396. if (!$menu_ord) return true;
  397.  
  398. return array(
  399. 'index.php', // Dashboard
  400. 'separator1', // First separator
  401. 'edit.php', // Posts
  402. 'edit.php?post_type=page', // Pages
  403. 'edit.php?post_type=blocks',
  404. 'edit.php?post_type=where_to',
  405. 'edit.php?post_type=whats_going_on',
  406. 'edit.php?post_type=sponsors',
  407. 'edit.php?post_type=event',
  408. 'separator2', // Second separator
  409. 'upload.php', // Media
  410. 'link-manager.php', // Links
  411. 'edit-comments.php', // Comments
  412. 'themes.php', // Appearance
  413. 'plugins.php', // Plugins
  414. 'users.php', // Users
  415. 'tools.php', // Tools
  416. 'options-general.php', // Settings
  417. 'separator-last', // Last separator
  418. );
  419. }
  420. add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order
  421. add_filter('menu_order', 'custom_menu_order');
  422.  
  423. //// Remove items
  424.  
  425. function edit_admin_menus() {
  426. global $menu;
  427. global $submenu;
  428.  
  429. $menu[5][0] = 'News'; // Change Posts name
  430. $submenu['edit.php'][5][0] = 'All News';
  431. $submenu['edit.php'][10][0] = 'Add News';
  432.  
  433. remove_menu_page('link-manager.php'); // Remove the Links Menu
  434. }
  435. add_action( 'admin_menu', 'edit_admin_menus' );
  436.  
  437.  
  438.  
  439. // post thumbnails
  440.  
  441. if ( function_exists( 'add_theme_support' ) ) {
  442. add_theme_support( 'post-thumbnails', array( 'post', 'where_to', 'whats_going_on' ) );
  443. set_post_thumbnail_size( 140, 105, true ); // default Post Thumbnail dimensions (cropped)
  444. }
  445.  
  446.  
  447. // conditional placeholder EM
  448.  
  449. /**
  450. * add some conditional output conditions for Events Manager
  451. * @param string $replacement
  452. * @param string $condition
  453. * @param string $match
  454. * @param object $EM_Event
  455. * @return string
  456. */
  457. function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
  458. if (is_object($EM_Event)) {
  459.  
  460. switch ($condition) {
  461.  
  462. // #_ATT{Premium}
  463. case 'has_att_premium':
  464. if (is_array($EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Premium']))
  465. $replacement = preg_replace('/\{\/?has_att_premium\}/', '', $match);
  466. else
  467. $replacement = '';
  468. break;
  469.  
  470. }
  471.  
  472. }
  473.  
  474. // return $replacement;
  475. return ‘filterEventOutputCondition’;
  476. }
  477.  
  478. add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);
  479.  
  480.  
  481.  
  482.  
  483. // there should be no blank lines below thing
  484. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement