functions.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. <?php
  2. /*
  3. Author: Eddie Machado
  4. URL: http://themble.com/bones/
  5. This is where you can drop your custom functions or
  6. just edit things like thumbnail sizes, header images,
  7. sidebars, comments, etc.
  8. */
  9. // LOAD BONES CORE (if you remove this, the theme will break)
  10. require_once( 'library/bones.php' );
  11. // CUSTOMIZE THE WORDPRESS ADMIN (off by default)
  12. // require_once( 'library/admin.php' );
  13. /*********************
  14. LAUNCH BONES
  15. Let's get everything up and running.
  16. *********************/
  17. function bones_ahoy() {
  18. //Allow editor style.
  19. add_editor_style( get_stylesheet_directory_uri() . '/library/css/editor-style.css' );
  20. // let's get language support going, if you need it
  21. load_theme_textdomain( 'bonestheme', get_template_directory() . '/library/translation' );
  22. // USE THIS TEMPLATE TO CREATE CUSTOM POST TYPES EASILY
  23. //require_once( 'library/custom-post-type.php' );
  24. // launching operation cleanup
  25. add_action( 'init', 'bones_head_cleanup' );
  26. // A better title
  27. add_filter( 'wp_title', 'rw_title', 10, 3 );
  28. // remove WP version from RSS
  29. add_filter( 'the_generator', 'bones_rss_version' );
  30. // remove pesky injected css for recent comments widget
  31. add_filter( 'wp_head', 'bones_remove_wp_widget_recent_comments_style', 1 );
  32. // clean up comment styles in the head
  33. add_action( 'wp_head', 'bones_remove_recent_comments_style', 1 );
  34. // clean up gallery output in wp
  35. add_filter( 'gallery_style', 'bones_gallery_style' );
  36. // enqueue base scripts and styles
  37. add_action( 'wp_enqueue_scripts', 'bones_scripts_and_styles', 999 );
  38. // ie conditional wrapper
  39. // launching this stuff after theme setup
  40. bones_theme_support();
  41. // adding sidebars to Wordpress (these are created in functions.php)
  42. add_action( 'widgets_init', 'bones_register_sidebars' );
  43. // cleaning up random code around images
  44. add_filter( 'the_content', 'bones_filter_ptags_on_images' );
  45. // cleaning up excerpt
  46. add_filter( 'excerpt_more', 'bones_excerpt_more' );
  47. } /* end bones ahoy */
  48. // let's get this party started
  49. add_action( 'after_setup_theme', 'bones_ahoy' );
  50. /************* OEMBED SIZE OPTIONS *************/
  51. if ( ! isset( $content_width ) ) {
  52. $content_width = 680;
  53. }
  54. /************* THUMBNAIL SIZE OPTIONS *************/
  55. // Thumbnail sizes
  56. add_image_size( 'rl-thumb-600', 600, 150, true );
  57. add_image_size( 'rl-thumb-300', 300, 100, true );
  58. add_image_size( 'projekt_thumb', 355, 236, true);
  59. add_image_size( 'general_thumb', 255, 255, true);
  60. add_image_size( 'slides_thumb', 1920, 600, true);
  61. // add_image_size( 'rl-mitarbeiter', 250, 250, true );
  62. // add_image_size( 'rl-kunden', 240, 240, true );
  63. add_filter( 'image_size_names_choose', 'bones_custom_image_sizes' );
  64. function bones_custom_image_sizes( $sizes ) {
  65. return array_merge( $sizes, array(
  66. 'rl-thumb-600' => __('600px by 150px'),
  67. 'rl-thumb-300' => __('300px by 100px'),
  68. 'general_thumb' => __('Mitarbeiter'),
  69. 'general_thumb' => __('Kunden'),
  70. 'projekt_thumb' => __('Projekt'),
  71. ) );
  72. }
  73. /*
  74. The function above adds the ability to use the dropdown menu to select
  75. the new images sizes you have just created from within the media manager
  76. when you add media to your content blocks. If you add more image sizes,
  77. duplicate one of the lines in the array and name it according to your
  78. new image size.
  79. */
  80. /************* THEME CUSTOMIZE *********************/
  81. /*
  82. A good tutorial for creating your own Sections, Controls and Settings:
  83. http://code.tutsplus.com/series/a-guide-to-the-wordpress-theme-customizer--wp-33722
  84. Good articles on modifying the default options:
  85. http://natko.com/changing-default-wordpress-theme-customization-api-sections/
  86. http://code.tutsplus.com/tutorials/digging-into-the-theme-customizer-components--wp-27162
  87. To do:
  88. - Create a js for the postmessage transport method
  89. - Create some sanitize functions to sanitize inputs
  90. - Create some boilerplate Sections, Controls and Settings
  91. */
  92. function bones_theme_customizer($wp_customize) {
  93. // $wp_customize calls go here.
  94. //
  95. // Uncomment the below lines to remove the default customize sections
  96. $wp_customize->remove_section('title_tagline');
  97. $wp_customize->remove_section('colors');
  98. $wp_customize->remove_section('background_image');
  99. $wp_customize->remove_section('static_front_page');
  100. $wp_customize->remove_section('nav');
  101. // Uncomment the below lines to remove the default controls
  102. $wp_customize->remove_control('blogdescription');
  103. // Uncomment the following to change the default section titles
  104. // $wp_customize->get_section('colors')->title = __( 'Theme Colors' );
  105. // $wp_customize->get_section('background_image')->title = __( 'Images' );
  106. }
  107. add_action( 'customize_register', 'bones_theme_customizer' );
  108. /************* ACTIVE SIDEBARS ********************/
  109. // Sidebars & Widgetizes Areas
  110. function bones_register_sidebars() {
  111. register_sidebar(array(
  112. 'id' => 'sidebar1',
  113. 'name' => __( 'Sidebar 1', 'bonestheme' ),
  114. 'description' => __( 'The first (primary) sidebar.', 'bonestheme' ),
  115. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  116. 'after_widget' => '</div>',
  117. 'before_title' => '<h4 class="widgettitle">',
  118. 'after_title' => '</h4>',
  119. ));
  120. /*
  121. to add more sidebars or widgetized areas, just copy
  122. and edit the above sidebar code. In order to call
  123. your new sidebar just use the following code:
  124. Just change the name to whatever your new
  125. sidebar's id is, for example:
  126. register_sidebar(array(
  127. 'id' => 'sidebar2',
  128. 'name' => __( 'Sidebar 2', 'bonestheme' ),
  129. 'description' => __( 'The second (secondary) sidebar.', 'bonestheme' ),
  130. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  131. 'after_widget' => '</div>',
  132. 'before_title' => '<h4 class="widgettitle">',
  133. 'after_title' => '</h4>',
  134. ));
  135. To call the sidebar in your template, you can just copy
  136. the sidebar.php file and rename it to your sidebar's name.
  137. So using the above example, it would be:
  138. sidebar-sidebar2.php
  139. */
  140. } // don't remove this bracket!
  141. /************* COMMENT LAYOUT *********************/
  142. // Comment Layout
  143. function bones_comments( $comment, $args, $depth ) {
  144. $GLOBALS['comment'] = $comment; ?>
  145. <div id="comment-<?php comment_ID(); ?>" <?php comment_class('cf'); ?>>
  146. <article class="cf">
  147. <header class="comment-author vcard">
  148. <?php
  149. /*
  150. this is the new responsive optimized comment image. It used the new HTML5 data-attribute to display comment gravatars on larger screens only. What this means is that on larger posts, mobile sites don't have a ton of requests for comment images. This makes load time incredibly fast! If you'd like to change it back, just replace it with the regular wordpress gravatar call:
  151. echo get_avatar($comment,$size='32',$default='<path_to_url>' );
  152. */
  153. ?>
  154. <?php // custom gravatar call ?>
  155. <?php
  156. // create variable
  157. $bgauthemail = get_comment_author_email();
  158. ?>
  159. <img data-gravatar="http://www.gravatar.com/avatar/<?php echo md5( $bgauthemail ); ?>?s=40" class="load-gravatar avatar avatar-48 photo" height="40" width="40" src="<?php echo get_template_directory_uri(); ?>/library/images/nothing.gif" />
  160. <?php // end custom gravatar call ?>
  161. <?php printf(__( '<cite class="fn">%1$s</cite> %2$s', 'bonestheme' ), get_comment_author_link(), edit_comment_link(__( '(Edit)', 'bonestheme' ),' ','') ) ?>
  162. <time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time(__( 'F jS, Y', 'bonestheme' )); ?> </a></time>
  163. </header>
  164. <?php if ($comment->comment_approved == '0') : ?>
  165. <div class="alert alert-info">
  166. <p><?php _e( 'Your comment is awaiting moderation.', 'bonestheme' ) ?></p>
  167. </div>
  168. <?php endif; ?>
  169. <section class="comment_content cf">
  170. <?php comment_text() ?>
  171. </section>
  172. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  173. </article>
  174. <?php // </li> is added by WordPress automatically ?>
  175. <?php
  176. } // don't remove this bracket!
  177. /*
  178. This is a modification of a function found in the
  179. twentythirteen theme where we can declare some
  180. external fonts. If you're using Google Fonts, you
  181. can replace these fonts, change it in your scss files
  182. and be up and running in seconds.
  183. */
  184. function bones_fonts() {
  185. wp_enqueue_style('googleFonts', '//fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic');
  186. }
  187. add_action('wp_enqueue_scripts', 'bones_fonts');
  188. // ************************************************************ \\
  189. // ************************************************************ \\
  190. // ************************************************************ \\
  191. function post_remove () //creating functions post_remove for removing menu item
  192. {
  193. remove_menu_page('edit.php');
  194. }
  195. add_action('admin_menu', 'post_remove');
  196. // https://blog.teamtreehouse.com/create-your-first-wordpress-custom-post-type
  197. https://developer.wordpress.org/reference/functions/register_post_type/#capability_type
  198. add_action('init', 'mitarbeiter', 0);
  199. function mitarbeiter() {
  200. $labels = array(
  201. 'name' => _x('Mitarbeiter', 'Post Type General Name', 'theme'),
  202. 'singular_name' => _x('Mitarbeiter', 'Post Type Singular Name', 'theme'),
  203. 'menu_name' => __('Mitarbeiter', 'theme'),
  204. 'name_admin_bar' => __('Mitarbeiter', 'theme'),
  205. 'parent_item_colon' => __('Parent Mitarbeiter:', 'theme'),
  206. 'all_items' => __('All Mitarbeiter', 'theme'),
  207. 'add_new_item' => __('Add New Mitarbeiter', 'theme'),
  208. 'add_new' => __('Add New', 'theme'),
  209. 'new_item' => __('New Mitarbeiter', 'theme'),
  210. 'edit_item' => __('Edit Mitarbeiter', 'theme'),
  211. 'update_item' => __('Update Mitarbeiter', 'theme'),
  212. 'view_item' => __('View Mitarbeiter', 'theme'),
  213. 'search_items' => __('Search Mitarbeiter', 'theme'),
  214. 'not_found' => __('Not found', 'theme'),
  215. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  216. );
  217. $args = array(
  218. 'label' => __('mitarbeiter', 'theme'),
  219. 'labels' => $labels,
  220. 'description' => __('Team', 'theme'),
  221. 'supports' => array('title', 'editor', 'thumbnail'),
  222. //'taxonomies' => array('category', 'post_tag'),
  223. 'hierarchical' => false,
  224. 'public' => true,
  225. 'show_ui' => true,
  226. 'show_in_menu' => true,
  227. 'menu_position' => 11,
  228. 'show_in_admin_bar' => true,
  229. 'show_in_nav_menus' => true,
  230. 'can_export' => true,
  231. 'has_archive' => true,
  232. 'exclude_from_search' => true,
  233. 'publicly_queryable' => true,
  234. 'capability_type' => 'page',
  235. 'menu_icon' => 'dashicons-id',
  236. );
  237. register_post_type( 'mitarbeiter', $args );
  238. }
  239. add_action('init', 'projekte', 0);
  240. function projekte() {
  241. $labels = array(
  242. 'name' => _x('Projekte', 'Post Type General Name', 'theme'),
  243. 'singular_name' => _x('Projek', 'Post Type Singular Name', 'theme'),
  244. 'menu_name' => __('Projekte', 'theme'),
  245. 'name_admin_bar' => __('Projekte', 'theme'),
  246. 'parent_item_colon' => __('Parent Projekte:', 'theme'),
  247. 'all_items' => __('All Projekte', 'theme'),
  248. 'add_new_item' => __('Add New project', 'theme'),
  249. 'add_new' => __('Add New', 'theme'),
  250. 'new_item' => __('New project', 'theme'),
  251. 'edit_item' => __('Edit project', 'theme'),
  252. 'update_item' => __('Update project', 'theme'),
  253. 'view_item' => __('View projects', 'theme'),
  254. 'search_items' => __('Search projects', 'theme'),
  255. 'not_found' => __('Not found', 'theme'),
  256. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  257. );
  258. $args = array(
  259. 'label' => __('projekte', 'theme'),
  260. 'labels' => $labels,
  261. 'description' => __('Team', 'theme'),
  262. 'supports' => array('title', 'thumbnail'),
  263. //'taxonomies' => array('category', 'post_tag'),
  264. 'hierarchical' => false,
  265. 'public' => true,
  266. 'show_ui' => true,
  267. 'show_in_menu' => true,
  268. 'menu_position' => 11,
  269. 'show_in_admin_bar' => true,
  270. 'show_in_nav_menus' => true,
  271. 'can_export' => true,
  272. 'has_archive' => true,
  273. 'exclude_from_search' => false,
  274. 'publicly_queryable' => true,
  275. 'capability_type' => 'page',
  276. 'menu_icon' => 'dashicons-store',
  277. );
  278. register_post_type( 'projekte', $args );
  279. }
  280. add_action('init', 'baugruppen', 0);
  281. function baugruppen() {
  282. $labels = array(
  283. 'name' => _x('Baugruppen', 'Post Type General Name', 'theme'),
  284. 'singular_name' => _x('Baugruppe', 'Post Type Singular Name', 'theme'),
  285. 'menu_name' => __('Baugruppen', 'theme'),
  286. 'name_admin_bar' => __('Baugruppen', 'theme'),
  287. 'parent_item_colon' => __('Parent Baugruppen:', 'theme'),
  288. 'all_items' => __('All Baugruppen', 'theme'),
  289. 'add_new_item' => __('Add New group', 'theme'),
  290. 'add_new' => __('Add New', 'theme'),
  291. 'new_item' => __('New group', 'theme'),
  292. 'edit_item' => __('Edit group', 'theme'),
  293. 'update_item' => __('Update group', 'theme'),
  294. 'view_item' => __('View groups', 'theme'),
  295. 'search_items' => __('Search groups', 'theme'),
  296. 'not_found' => __('Not found', 'theme'),
  297. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  298. );
  299. $args = array(
  300. 'label' => __('baugruppen', 'theme'),
  301. 'labels' => $labels,
  302. 'description' => __('Team', 'theme'),
  303. 'supports' => array('title', 'thumbnail'),
  304. //'taxonomies' => array('category', 'post_tag'),
  305. 'hierarchical' => false,
  306. 'public' => true,
  307. 'show_ui' => true,
  308. 'show_in_menu' => true,
  309. 'menu_position' => 11,
  310. 'show_in_admin_bar' => true,
  311. 'show_in_nav_menus' => true,
  312. 'can_export' => true,
  313. 'has_archive' => true,
  314. 'exclude_from_search' => false,
  315. 'publicly_queryable' => true,
  316. 'capability_type' => 'page',
  317. 'menu_icon' => 'dashicons-groups',
  318. );
  319. register_post_type( 'baugruppen', $args );
  320. }
  321. add_action('init', 'clients', 0);
  322. function clients() {
  323. $labels = array(
  324. 'name' => _x('Clients', 'Post Type General Name', 'theme'),
  325. 'singular_name' => _x('Client', 'Post Type Singular Name', 'theme'),
  326. 'menu_name' => __('Clients', 'theme'),
  327. 'name_admin_bar' => __('Clients', 'theme'),
  328. 'parent_item_colon' => __('Parent Clients:', 'theme'),
  329. 'all_items' => __('All Clients', 'theme'),
  330. 'add_new_item' => __('Add New client', 'theme'),
  331. 'add_new' => __('Add New', 'theme'),
  332. 'new_item' => __('New client', 'theme'),
  333. 'edit_item' => __('Edit client', 'theme'),
  334. 'update_item' => __('Update client', 'theme'),
  335. 'view_item' => __('View clients', 'theme'),
  336. 'search_items' => __('Search clients', 'theme'),
  337. 'not_found' => __('Not found', 'theme'),
  338. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  339. );
  340. $args = array(
  341. 'label' => __('clients', 'theme'),
  342. 'labels' => $labels,
  343. 'description' => __('Team', 'theme'),
  344. 'supports' => array('title', 'thumbnail'),
  345. //'taxonomies' => array('category', 'post_tag'),
  346. 'hierarchical' => false,
  347. 'public' => true,
  348. 'show_ui' => true,
  349. 'show_in_menu' => true,
  350. 'menu_position' => 11,
  351. 'show_in_admin_bar' => true,
  352. 'show_in_nav_menus' => true,
  353. 'can_export' => true,
  354. 'has_archive' => true,
  355. 'exclude_from_search' => false,
  356. 'publicly_queryable' => true,
  357. 'capability_type' => 'page',
  358. 'menu_icon' => 'dashicons-smiley',
  359. );
  360. register_post_type( 'clients', $args );
  361. }
  362. add_action('init', 'testimonials', 0);
  363. function testimonials() {
  364. $labels = array(
  365. 'name' => _x('testimonials', 'Post Type General Name', 'theme'),
  366. 'singular_name' => _x('Testimonial', 'Post Type Singular Name', 'theme'),
  367. 'menu_name' => __('Testimonials', 'theme'),
  368. 'name_admin_bar' => __('Testimonials', 'theme'),
  369. 'parent_item_colon' => __('Parent testimonials:', 'theme'),
  370. 'all_items' => __('All testimonials', 'theme'),
  371. 'add_new_item' => __('Add New testimonial', 'theme'),
  372. 'add_new' => __('Add New', 'theme'),
  373. 'new_item' => __('New testimonial', 'theme'),
  374. 'edit_item' => __('Edit testimonial', 'theme'),
  375. 'update_item' => __('Update testimonial', 'theme'),
  376. 'view_item' => __('View testimonials', 'theme'),
  377. 'search_items' => __('Search testimonials', 'theme'),
  378. 'not_found' => __('Not found', 'theme'),
  379. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  380. );
  381. $args = array(
  382. 'label' => __('testimonials', 'theme'),
  383. 'labels' => $labels,
  384. 'description' => __('Team', 'theme'),
  385. 'supports' => array('title', 'thumbnail'),
  386. //'taxonomies' => array('category', 'post_tag'),
  387. 'hierarchical' => false,
  388. 'public' => true,
  389. 'show_ui' => true,
  390. 'show_in_menu' => true,
  391. 'menu_position' => 11,
  392. 'show_in_admin_bar' => true,
  393. 'show_in_nav_menus' => true,
  394. 'can_export' => true,
  395. 'has_archive' => true,
  396. 'exclude_from_search' => false,
  397. 'publicly_queryable' => true,
  398. 'capability_type' => 'page',
  399. 'menu_icon' => 'dashicons-format-quote',
  400. );
  401. register_post_type( 'testimonials', $args );
  402. }
  403. add_action('init', 'slides', 0);
  404. function slides() {
  405. $labels = array(
  406. 'name' => _x('Slides', 'Post Type General Name', 'theme'),
  407. 'singular_name' => _x('Slide', 'Post Type Singular Name', 'theme'),
  408. 'menu_name' => __('Slides', 'theme'),
  409. 'name_admin_bar' => __('Slides', 'theme'),
  410. 'parent_item_colon' => __('Parent slides:', 'theme'),
  411. 'all_items' => __('All slides', 'theme'),
  412. 'add_new_item' => __('Add New slide', 'theme'),
  413. 'add_new' => __('Add New', 'theme'),
  414. 'new_item' => __('New slide', 'theme'),
  415. 'edit_item' => __('Edit slide', 'theme'),
  416. 'update_item' => __('Update slide', 'theme'),
  417. 'view_item' => __('View slides', 'theme'),
  418. 'search_items' => __('Search slides', 'theme'),
  419. 'not_found' => __('Not found', 'theme'),
  420. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  421. );
  422. $args = array(
  423. 'label' => __('slides', 'theme'),
  424. 'labels' => $labels,
  425. 'description' => __('Team', 'theme'),
  426. 'supports' => array('title', 'thumbnail'),
  427. //'taxonomies' => array('category', 'post_tag'),
  428. 'hierarchical' => false,
  429. 'public' => true,
  430. 'show_ui' => true,
  431. 'show_in_menu' => true,
  432. 'menu_position' => 11,
  433. 'show_in_admin_bar' => true,
  434. 'show_in_nav_menus' => true,
  435. 'can_export' => true,
  436. 'has_archive' => true,
  437. 'exclude_from_search' => false,
  438. 'publicly_queryable' => true,
  439. 'capability_type' => 'page',
  440. 'menu_icon' => 'dashicons-format-image',
  441. );
  442. register_post_type( 'slides', $args );
  443. }
  444. add_action('init', 'geschaeftfelder', 0);
  445. function geschaeftfelder() {
  446. $labels = array(
  447. 'name' => _x('Geschäftsfelder', 'Post Type General Name', 'theme'),
  448. 'singular_name' => _x('Slide', 'Post Type Singular Name', 'theme'),
  449. 'menu_name' => __('Geschäftsfelder', 'theme'),
  450. 'name_admin_bar' => __('Geschäftsfelder', 'theme'),
  451. 'parent_item_colon' => __('Parent geschäftsfelder:', 'theme'),
  452. 'all_items' => __('All geschäftsfelder', 'theme'),
  453. 'add_new_item' => __('Add New geschäftsfeld', 'theme'),
  454. 'add_new' => __('Add New', 'theme'),
  455. 'new_item' => __('New geschäftsfeld', 'theme'),
  456. 'edit_item' => __('Edit geschäftsfeld', 'theme'),
  457. 'update_item' => __('Update geschäftsfeld', 'theme'),
  458. 'view_item' => __('View geschäftsfelder', 'theme'),
  459. 'search_items' => __('Search geschäftsfelder', 'theme'),
  460. 'not_found' => __('Not found', 'theme'),
  461. 'not_found_in_trash' => __('Not found in Trash', 'theme'),
  462. );
  463. $args = array(
  464. 'label' => __('geschaeftfelder', 'theme'),
  465. 'labels' => $labels,
  466. 'description' => __('Team', 'theme'),
  467. 'supports' => array('title', 'thumbnail'),
  468. //'taxonomies' => array('category', 'post_tag'),
  469. 'hierarchical' => false,
  470. 'public' => true,
  471. 'show_ui' => true,
  472. 'show_in_menu' => true,
  473. 'menu_position' => 11,
  474. 'show_in_admin_bar' => true,
  475. 'show_in_nav_menus' => true,
  476. 'can_export' => true,
  477. 'has_archive' => true,
  478. 'exclude_from_search' => false,
  479. 'publicly_queryable' => true,
  480. 'capability_type' => 'page',
  481. 'menu_icon' => 'dashicons-building',
  482. );
  483. register_post_type( 'geschaeftfelder', $args );
  484. }
  485. add_action("admin_init", "admin_init");
  486. function admin_init(){
  487. // mitarbetier
  488. add_meta_box("mitarbeiter-position", "Position", "mitarbeiter_position", "mitarbeiter", "normal", "low");
  489. add_meta_box("mitarbeiter-email", "Email", "mitarbeiter_email", "mitarbeiter", "normal", "low");
  490. add_meta_box("mitarbeiter-beschreibung", "Beschreibung", "mitarbeiter_beschreibung", "mitarbeiter", "normal", "low");
  491. add_meta_box("mitarbeiter-tel", "Telefonnummer", "mitarbeiter_tel", "mitarbeiter", "normal", "low");
  492. // Projekte
  493. add_meta_box("projekt-beschreibung", "Description", "projekt_beschreibung", "projekte", "normal", "low");
  494. add_meta_box("projekt-link", "Link", "projekt_link", "projekte", "normal", "low");
  495. // Baugruppen
  496. add_meta_box("baugruppe-link", "Link", "baugruppe_link", "baugruppen", "normal", "low");
  497. // Baugruppen
  498. add_meta_box("client-link", "Link", "client_link", "clients", "normal", "low");
  499. // Testimonials
  500. add_meta_box("bericht-text", "Text", "testimonial_text", "testimonials", "normal", "low");
  501. add_meta_box("bericht-autor", "Autor", "testimonial_autor", "testimonials", "normal", "low");
  502. add_meta_box("bericht-link", "Link", "testimonial_link", "testimonials", "normal", "low");
  503. // Slides
  504. add_meta_box("slide-text", "Text", "slide_text", "slides", "normal", "low");
  505. add_meta_box("slide-link-text", "Link-text", "slide_link_text", "slides", "normal", "low");
  506. add_meta_box("slide-link", "Link", "slide_link", "slides", "normal", "low");
  507. // geschaeftfelder
  508. add_meta_box("geschaeftfeld-text", "Text", "geschaeftfeld_text", "geschaeftfelder", "normal", "low");
  509. }
  510. function mitarbeiter_email(){
  511. global $post;
  512. $custom = get_post_custom($post->ID);
  513. $mitarbeiter_email = $custom["mitarbeiter_email"][0];
  514. ?>
  515. <label>Email:</label>
  516. <input name="mitarbeiter_email" value="<?php echo $mitarbeiter_email; ?>" />
  517. <?php
  518. }
  519. function mitarbeiter_position(){
  520. global $post;
  521. $custom = get_post_custom($post->ID);
  522. $mitarbeiter_position = $custom["mitarbeiter_position"][0];
  523. ?>
  524. <label>Position:</label>
  525. <input name="mitarbeiter_position" value="<?php echo $mitarbeiter_position; ?>" />
  526. <?php
  527. }
  528. function mitarbeiter_beschreibung(){
  529. global $post;
  530. $custom = get_post_custom($post->ID);
  531. $mitarbeiter_beschreibung = $custom["mitarbeiter_beschreibung"][0];
  532. ?>
  533. <label>Beschreibung:</label>
  534. <input name="mitarbeiter_beschreibung" maxlength="84" value="<?php echo $mitarbeiter_beschreibung; ?>" />
  535. <?php
  536. }
  537. function mitarbeiter_tel(){
  538. global $post;
  539. $custom = get_post_custom($post->ID);
  540. $mitarbeiter_tel = $custom["mitarbeiter_tel"][0];
  541. ?>
  542. <label>Tel:</label>
  543. <input name="mitarbeiter_tel" value="<?php echo $mitarbeiter_tel; ?>" />
  544. <?php
  545. }
  546. function projekt_beschreibung(){
  547. global $post;
  548. $custom = get_post_custom($post->ID);
  549. $projekt_beschreibung = $custom["projekt_beschreibung"][0];
  550. ?>
  551. <label>Description:</label>
  552. <input name="projekt_beschreibung" value="<?php echo $projekt_beschreibung; ?>" />
  553. <?php
  554. }
  555. function projekt_link(){
  556. global $post;
  557. $custom = get_post_custom($post->ID);
  558. $projekt_link = $custom["projekt_link"][0];
  559. ?>
  560. <label>Link:</label>
  561. <input name="projekt_link" value="<?php echo $projekt_link; ?>" />
  562. <?php
  563. }
  564. function baugruppe_link(){
  565. global $post;
  566. $custom = get_post_custom($post->ID);
  567. $baugruppe_link = $custom["baugruppe_link"][0];
  568. ?>
  569. <label>Link:</label>
  570. <input name="baugruppe_link" value="<?php echo $baugruppe_link; ?>" />
  571. <?php
  572. }
  573. function client_link(){
  574. global $post;
  575. $custom = get_post_custom($post->ID);
  576. $client_link = $custom["client_link"][0];
  577. ?>
  578. <label>Link:</label>
  579. <input name="client_link" value="<?php echo $client_link; ?>" />
  580. <?php
  581. }
  582. function testimonial_text(){
  583. global $post;
  584. $custom = get_post_custom($post->ID);
  585. $testimonial_text = $custom["testimonial_text"][0];
  586. ?>
  587. <label>Text:</label>
  588. <input name="testimonial_text" value="<?php echo $testimonial_text; ?>" />
  589. <?php
  590. }
  591. function testimonial_autor(){
  592. global $post;
  593. $custom = get_post_custom($post->ID);
  594. $testimonial_autor = $custom["testimonial_autor"][0];
  595. ?>
  596. <label>Author:</label>
  597. <input name="testimonial_autor" value="<?php echo $testimonial_autor; ?>" />
  598. <?php
  599. }
  600. function testimonial_link(){
  601. global $post;
  602. $custom = get_post_custom($post->ID);
  603. $testimonial_link = $custom["testimonial_link"][0];
  604. ?>
  605. <label>Author:</label>
  606. <input name="testimonial_link" value="<?php echo $testimonial_link; ?>" />
  607. <?php
  608. }
  609. function slide_text(){
  610. global $post;
  611. $custom = get_post_custom($post->ID);
  612. $slide_text = $custom["slide_text"][0];
  613. ?>
  614. <label>Text:</label>
  615. <input name="slide_text" value="<?php echo $slide_text; ?>" />
  616. <?php
  617. }
  618. function slide_link_text(){
  619. global $post;
  620. $custom = get_post_custom($post->ID);
  621. $slide_link_text = $custom["slide_link_text"][0];
  622. ?>
  623. <label>Slide link text:</label>
  624. <input name="slide_link_text" value="<?php echo $slide_link_text; ?>" />
  625. <?php
  626. }
  627. function slide_link(){
  628. global $post;
  629. $custom = get_post_custom($post->ID);
  630. $slide_link = $custom["slide_link"][0];
  631. ?>
  632. <label>Slide link:</label>
  633. <input name="slide_link" value="<?php echo $slide_link; ?>" />
  634. <?php
  635. }
  636. function geschaeftfeld_text(){
  637. global $post;
  638. $custom = get_post_custom($post->ID);
  639. $geschaeftfeld_text = $custom["geschaeftfeld_text"][0];
  640. ?>
  641. <label>Text:</label>
  642. <input name="geschaeftfeld_text" value="<?php echo $geschaeftfeld_text; ?>" />
  643. <?php
  644. }
  645. add_action('save_post', 'save_details');
  646. function save_details(){
  647. global $post;
  648. // mitarbeiter
  649. update_post_meta($post->ID, "mitarbeiter_position", $_POST["mitarbeiter_position"]);
  650. update_post_meta($post->ID, "mitarbeiter_email", $_POST["mitarbeiter_email"]);
  651. update_post_meta($post->ID, "mitarbeiter_beschreibung", $_POST["mitarbeiter_beschreibung"]);
  652. update_post_meta($post->ID, "mitarbeiter_tel", $_POST["mitarbeiter_tel"]);
  653. // Projekte
  654. update_post_meta($post->ID, "projekt_beschreibung", $_POST["projekt_beschreibung"]);
  655. update_post_meta($post->ID, "projekt_link", $_POST["projekt_link"]);
  656. // baugruppen
  657. update_post_meta($post->ID, "baugruppe_link", $_POST["baugruppe_link"]);
  658. // clients
  659. update_post_meta($post->ID, "client_link", $_POST["client_link"]);
  660. // testimonials
  661. update_post_meta($post->ID, "testimonial_text", $_POST["testimonial_text"]);
  662. update_post_meta($post->ID, "testimonial_autor", $_POST["testimonial_autor"]);
  663. update_post_meta($post->ID, "testimonial_link", $_POST["testimonial_link"]);
  664. // slides
  665. update_post_meta($post->ID, "slide_text", $_POST["slide_text"]);
  666. update_post_meta($post->ID, "slide_link_text", $_POST["slide_link_text"]);
  667. update_post_meta($post->ID, "slide_link", $_POST["slide_link"]);
  668. // geschaeftfeld
  669. update_post_meta($post->ID, "geschaeftfeld_text", $_POST["geschaeftfeld_text"]);
  670. }
  671. // add_image_size( 'mitarbeiter_thumb', 255, 255, true);
  672. /*
  673. Baugrupen
  674. Kunden
  675. Testimonials
  676. */
  677. function theme_settings_page()
  678. {
  679. ?>
  680. <div class="wrap">
  681. <h1>Theme Panel</h1>
  682. <form method="post" action="options.php">
  683. <?php
  684. settings_fields("section");
  685. do_settings_sections("theme-options");
  686. submit_button();
  687. ?>
  688. </form>
  689. </div>
  690. <?php
  691. }
  692. function add_theme_menu_item()
  693. {
  694. add_menu_page("Text blocks", "Text blocks", "manage_options", "theme-panel", "theme_settings_page", null, 99);
  695. }
  696. add_action("admin_menu", "add_theme_menu_item");
  697. function kontakt_daten()
  698. {
  699. ?>
  700. <textarea type="text" rows="10" cols="30" name="kontakt_daten" id="kontakt_daten" style="width: 50%;" >
  701. <?php echo get_option('kontakt_daten', '<h3 class="small-title">Kontakt</h3><p>realitylab gmbh <br>Ernst-Melchior-Gasse 11/1/G1<br>1020 Wien<br>Fon: (43) 01 996 20 15 - 0<br>Mail: office@realitylab.at<br></p><!--<div class="social-footer"><a href="#"><i class="fa fa-facebook icon-round"></i></a><a href="#"><i class="fa fa-twitter icon-round"></i></a><a href="#"><i class="fa fa-linkedin icon-round"></i></a></div> -->'); ?>
  702. </textarea>
  703. <?php
  704. }
  705. function zweite_spalte()
  706. {
  707. ?>
  708. <textarea type="text" rows="10" cols="30" name="zweite_spalte" id="zweite_spalte" style="width: 50%;" >
  709. <?php echo get_option('zweite_spalte', ''); ?>
  710. </textarea>
  711. <?php
  712. }
  713. function dritte_spalte()
  714. {
  715. ?>
  716. <textarea type="text" rows="10" cols="30" name="dritte_spalte" id="dritte_spalte" style="width: 50%;" >
  717. <?php echo get_option('dritte_spalte', '<p>Wir sind mitglied bei:</p><p>&nbsp;</p><p><img src="https://dummyimage.com/30x30/000000/fff.jpg" alt="dummy" /> <img src="https://dummyimage.com/30x30/000000/fff.jpg" alt="dummy" /></p>'); ?>
  718. </textarea>
  719. <?php
  720. }
  721. function vierte_spalte()
  722. {
  723. ?>
  724. <textarea type="text" rows="10" cols="30" name="vierte_spalte" id="vierte_spalte" style="width: 50%;" >
  725. <?php echo get_option('vierte_spalte', ''); ?>
  726. </textarea>
  727. <?php
  728. }
  729. function display_theme_panel_fields()
  730. {
  731. add_settings_section("section", "Textblöcke. HTML is erlaubt.", null, "theme-options");
  732. add_settings_field("kontakt_daten", "Kontaktdaten (1. Spalte im Footer)", "kontakt_daten", "theme-options", "section");
  733. register_setting("section", "kontakt_daten");
  734. add_settings_field("zweite_spalte", "2. Spalte im Footer", "zweite_spalte", "theme-options", "section");
  735. register_setting("section", "zweite_spalte");
  736. add_settings_field("dritte_spalte", "3. Spalte im Footer", "dritte_spalte", "theme-options", "section");
  737. register_setting("section", "dritte_spalte");
  738. add_settings_field("vierte_spalte", "4. Spalte im Footer", "vierte_spalte", "theme-options", "section");
  739. register_setting("section", "vierte_spalte");
  740. /*
  741. add_settings_section("section", "All Settings", null, "theme-options");
  742. add_settings_field("twitter_url", "Twitter Profile Url", "display_twitter_element", "theme-options", "section");
  743. add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_element", "theme-options", "section");
  744. register_setting("section", "twitter_url");
  745. register_setting("section", "facebook_url"); */
  746. }
  747. add_action("admin_init", "display_theme_panel_fields");
  748. function encode_email_shortcode($atts, $content = null) {
  749. for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
  750. return '<a class="encoded-email" href="mailto:' . $encodedmail . '"><i class="fa fa-envelope" aria-hidden="true"></i></a>';
  751. }
  752. add_shortcode('email', 'encode_email_shortcode');
  753. /* DON'T DELETE THIS CLOSING TAG */ ?>