functions.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  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. add_meta_box("mitarbeiter-cv", "Link zum CV", "mitarbeiter_cv", "mitarbeiter", "normal", "low");
  493. // Projekte
  494. add_meta_box("projekt-beschreibung", "Description", "projekt_beschreibung", "projekte", "normal", "low");
  495. add_meta_box("projekt-link", "Link", "projekt_link", "projekte", "normal", "low");
  496. // Baugruppen
  497. add_meta_box("baugruppe-link", "Link", "baugruppe_link", "baugruppen", "normal", "low");
  498. // Baugruppen
  499. add_meta_box("client-link", "Link", "client_link", "clients", "normal", "low");
  500. // Testimonials
  501. add_meta_box("bericht-text", "Text", "testimonial_text", "testimonials", "normal", "low");
  502. add_meta_box("bericht-autor", "Autor", "testimonial_autor", "testimonials", "normal", "low");
  503. add_meta_box("bericht-link", "Link", "testimonial_link", "testimonials", "normal", "low");
  504. // Slides
  505. add_meta_box("slide-text", "Text", "slide_text", "slides", "normal", "low");
  506. add_meta_box("slide-link-text", "Link-text", "slide_link_text", "slides", "normal", "low");
  507. add_meta_box("slide-link", "Link", "slide_link", "slides", "normal", "low");
  508. // geschaeftfelder
  509. add_meta_box("geschaeftfeld-text", "Text", "geschaeftfeld_text", "geschaeftfelder", "normal", "low");
  510. }
  511. function mitarbeiter_email(){
  512. global $post;
  513. $custom = get_post_custom($post->ID);
  514. $mitarbeiter_email = $custom["mitarbeiter_email"][0];
  515. ?>
  516. <label>Email:</label>
  517. <input name="mitarbeiter_email" value="<?php echo $mitarbeiter_email; ?>" />
  518. <?php
  519. }
  520. function mitarbeiter_position(){
  521. global $post;
  522. $custom = get_post_custom($post->ID);
  523. $mitarbeiter_position = $custom["mitarbeiter_position"][0];
  524. ?>
  525. <label>Position:</label>
  526. <input name="mitarbeiter_position" value="<?php echo $mitarbeiter_position; ?>" />
  527. <?php
  528. }
  529. function mitarbeiter_beschreibung(){
  530. global $post;
  531. $custom = get_post_custom($post->ID);
  532. $mitarbeiter_beschreibung = $custom["mitarbeiter_beschreibung"][0];
  533. ?>
  534. <label>Beschreibung:</label>
  535. <input name="mitarbeiter_beschreibung" maxlength="84" value="<?php echo $mitarbeiter_beschreibung; ?>" />
  536. <?php
  537. }
  538. function mitarbeiter_tel(){
  539. global $post;
  540. $custom = get_post_custom($post->ID);
  541. $mitarbeiter_tel = $custom["mitarbeiter_tel"][0];
  542. ?>
  543. <label>Tel:</label>
  544. <input name="mitarbeiter_tel" value="<?php echo $mitarbeiter_tel; ?>" />
  545. <?php
  546. }
  547. function mitarbeiter_cv(){
  548. global $post;
  549. $custom = get_post_custom($post->ID);
  550. $mitarbeiter_cv = $custom["mitarbeiter_cv"][0];
  551. ?>
  552. <label>Link zum CV:</label>
  553. <input name="mitarbeiter_cv" value="<?php echo $mitarbeiter_cv; ?>" />
  554. <?php
  555. }
  556. function projekt_beschreibung(){
  557. global $post;
  558. $custom = get_post_custom($post->ID);
  559. $projekt_beschreibung = $custom["projekt_beschreibung"][0];
  560. ?>
  561. <label>Description:</label>
  562. <input name="projekt_beschreibung" value="<?php echo $projekt_beschreibung; ?>" />
  563. <?php
  564. }
  565. function projekt_link(){
  566. global $post;
  567. $custom = get_post_custom($post->ID);
  568. $projekt_link = $custom["projekt_link"][0];
  569. ?>
  570. <label>Link:</label>
  571. <input name="projekt_link" value="<?php echo $projekt_link; ?>" />
  572. <?php
  573. }
  574. function baugruppe_link(){
  575. global $post;
  576. $custom = get_post_custom($post->ID);
  577. $baugruppe_link = $custom["baugruppe_link"][0];
  578. ?>
  579. <label>Link:</label>
  580. <input name="baugruppe_link" value="<?php echo $baugruppe_link; ?>" />
  581. <?php
  582. }
  583. function client_link(){
  584. global $post;
  585. $custom = get_post_custom($post->ID);
  586. $client_link = $custom["client_link"][0];
  587. ?>
  588. <label>Link:</label>
  589. <input name="client_link" value="<?php echo $client_link; ?>" />
  590. <?php
  591. }
  592. function testimonial_text(){
  593. global $post;
  594. $custom = get_post_custom($post->ID);
  595. $testimonial_text = $custom["testimonial_text"][0];
  596. ?>
  597. <label>Text:</label>
  598. <input name="testimonial_text" value="<?php echo $testimonial_text; ?>" />
  599. <?php
  600. }
  601. function testimonial_autor(){
  602. global $post;
  603. $custom = get_post_custom($post->ID);
  604. $testimonial_autor = $custom["testimonial_autor"][0];
  605. ?>
  606. <label>Author:</label>
  607. <input name="testimonial_autor" value="<?php echo $testimonial_autor; ?>" />
  608. <?php
  609. }
  610. function testimonial_link(){
  611. global $post;
  612. $custom = get_post_custom($post->ID);
  613. $testimonial_link = $custom["testimonial_link"][0];
  614. ?>
  615. <label>Author:</label>
  616. <input name="testimonial_link" value="<?php echo $testimonial_link; ?>" />
  617. <?php
  618. }
  619. function slide_text(){
  620. global $post;
  621. $custom = get_post_custom($post->ID);
  622. $slide_text = $custom["slide_text"][0];
  623. ?>
  624. <label>Text:</label>
  625. <input name="slide_text" value="<?php echo $slide_text; ?>" />
  626. <?php
  627. }
  628. function slide_link_text(){
  629. global $post;
  630. $custom = get_post_custom($post->ID);
  631. $slide_link_text = $custom["slide_link_text"][0];
  632. ?>
  633. <label>Slide link text:</label>
  634. <input name="slide_link_text" value="<?php echo $slide_link_text; ?>" />
  635. <?php
  636. }
  637. function slide_link(){
  638. global $post;
  639. $custom = get_post_custom($post->ID);
  640. $slide_link = $custom["slide_link"][0];
  641. ?>
  642. <label>Slide link:</label>
  643. <input name="slide_link" value="<?php echo $slide_link; ?>" />
  644. <?php
  645. }
  646. function geschaeftfeld_text(){
  647. global $post;
  648. $custom = get_post_custom($post->ID);
  649. $geschaeftfeld_text = $custom["geschaeftfeld_text"][0];
  650. ?>
  651. <label>Text:</label>
  652. <input name="geschaeftfeld_text" value="<?php echo $geschaeftfeld_text; ?>" />
  653. <?php
  654. }
  655. add_action('save_post', 'save_details');
  656. function save_details(){
  657. global $post;
  658. // mitarbeiter
  659. update_post_meta($post->ID, "mitarbeiter_position", $_POST["mitarbeiter_position"]);
  660. update_post_meta($post->ID, "mitarbeiter_email", $_POST["mitarbeiter_email"]);
  661. update_post_meta($post->ID, "mitarbeiter_beschreibung", $_POST["mitarbeiter_beschreibung"]);
  662. update_post_meta($post->ID, "mitarbeiter_tel", $_POST["mitarbeiter_tel"]);
  663. update_post_meta($post->ID, "mitarbeiter_cv", $_POST["mitarbeiter_cv"]);
  664. // Projekte
  665. update_post_meta($post->ID, "projekt_beschreibung", $_POST["projekt_beschreibung"]);
  666. update_post_meta($post->ID, "projekt_link", $_POST["projekt_link"]);
  667. // baugruppen
  668. update_post_meta($post->ID, "baugruppe_link", $_POST["baugruppe_link"]);
  669. // clients
  670. update_post_meta($post->ID, "client_link", $_POST["client_link"]);
  671. // testimonials
  672. update_post_meta($post->ID, "testimonial_text", $_POST["testimonial_text"]);
  673. update_post_meta($post->ID, "testimonial_autor", $_POST["testimonial_autor"]);
  674. update_post_meta($post->ID, "testimonial_link", $_POST["testimonial_link"]);
  675. // slides
  676. update_post_meta($post->ID, "slide_text", $_POST["slide_text"]);
  677. update_post_meta($post->ID, "slide_link_text", $_POST["slide_link_text"]);
  678. update_post_meta($post->ID, "slide_link", $_POST["slide_link"]);
  679. // geschaeftfeld
  680. update_post_meta($post->ID, "geschaeftfeld_text", $_POST["geschaeftfeld_text"]);
  681. }
  682. // add_image_size( 'mitarbeiter_thumb', 255, 255, true);
  683. /*
  684. Baugrupen
  685. Kunden
  686. Testimonials
  687. */
  688. function theme_settings_page()
  689. {
  690. ?>
  691. <div class="wrap">
  692. <h1>Theme Panel</h1>
  693. <form method="post" action="options.php">
  694. <?php
  695. settings_fields("section");
  696. do_settings_sections("theme-options");
  697. submit_button();
  698. ?>
  699. </form>
  700. </div>
  701. <?php
  702. }
  703. function add_theme_menu_item()
  704. {
  705. add_menu_page("RL - Einstellungen", "RL - Einstellungen", "manage_options", "theme-panel", "theme_settings_page", null, 99);
  706. }
  707. add_action("admin_menu", "add_theme_menu_item");
  708. function gf_titel()
  709. {
  710. ?>
  711. <textarea type="text" rows="10" cols="30" name="gf_titel" id="gf_titel" style="width: 50%;" ><?php echo get_option('gf_titel', 'Dafür arbeiten wir <strong>ODER</strong> was uns beschäftigt'); ?>
  712. </textarea>
  713. <?php
  714. }
  715. function gf_extra()
  716. {
  717. ?>
  718. <textarea type="text" rows="10" cols="30" name="gf_extra" id="gf_extra" style="width: 50%;" ><?php echo get_option('gf_extra', 'Erfahren Sie mehr <strong>ODER</strong> mehr+'); ?>
  719. </textarea>
  720. <?php
  721. }
  722. function pr_titel()
  723. {
  724. ?>
  725. <textarea type="text" rows="10" cols="30" name="pr_titel" id="pr_titel" style="width: 50%;" ><?php echo get_option('pr_titel', '<h2 class="section-title">Ausgewählte Projekte</h2>'); ?>
  726. </textarea>
  727. <?php
  728. }
  729. function pr_extra()
  730. {
  731. ?>
  732. <textarea type="text" rows="10" cols="30" name="pr_extra" id="pr_extra" style="width: 50%;" ><?php echo get_option('pr_extra', '<p>Alle Projekte finden Sie unter <a title="https://gemeinschaffen.com" href="https://gemeinschaffen.com">https://gemeinschaffen.com</a></p>'); ?>
  733. </textarea>
  734. <?php
  735. }
  736. function separator()
  737. {
  738. ?>
  739. <hr style="border-top: 1px solid black;" >
  740. <?php
  741. }
  742. function kontakt_daten()
  743. {
  744. $content = get_option('kontakt_daten', 'Erfahren Sie mehr <strong>ODER</strong> mehr+');
  745. echo '<div class="" style="width: 75%;" >';
  746. wp_editor( $content, 'kontakt_daten', array(
  747. 'wpautop' => false,
  748. 'textarea_name' => 'kontakt_daten',
  749. 'media_buttons' => false,
  750. )
  751. );
  752. echo '</div>';
  753. }
  754. function zweite_spalte()
  755. {
  756. $content = get_option('zweite_spalte', 'Erfahren Sie mehr <strong>ODER</strong> mehr+');
  757. echo '<div class="" style="width: 75%;" >';
  758. wp_editor( $content, 'zweite_spalte', array(
  759. 'wpautop' => false,
  760. 'textarea_name' => 'zweite_spalte',
  761. 'media_buttons' => false,
  762. )
  763. );
  764. echo '</div>';
  765. }
  766. function dritte_spalte()
  767. {
  768. $content = get_option('dritte_spalte', 'Erfahren Sie mehr <strong>ODER</strong> mehr+');
  769. echo '<div class="" style="width: 75%;" >';
  770. wp_editor( $content, 'dritte_spalte', array(
  771. 'wpautop' => false,
  772. 'textarea_name' => 'dritte_spalte',
  773. 'media_buttons' => false,
  774. )
  775. );
  776. echo '</div>';
  777. }
  778. function vierte_spalte()
  779. {
  780. ?>
  781. <textarea type="text" rows="10" cols="30" name="vierte_spalte" id="vierte_spalte" style="width: 50%;" ><?php echo get_option('vierte_spalte', ''); ?>
  782. </textarea>
  783. <?php
  784. }
  785. function display_theme_panel_fields()
  786. {
  787. // add_settings_section("section", "Geschäftsfelder Textblöcke. HTML is erlaubt.", null, "theme-options");
  788. add_settings_section("section", "Textblöcke. HTML is erlaubt.", null, "theme-options");
  789. add_settings_field("gf_titel", "Geschäftsfelder Titel", "gf_titel", "theme-options", "section");
  790. register_setting("section", "gf_titel");
  791. add_settings_field("gf_extra", "Geschäftsfelder extra Text", "gf_extra", "theme-options", "section");
  792. register_setting("section", "gf_extra");
  793. add_settings_field("separator-a", "", "separator", "theme-options", "section");
  794. add_settings_field("pr_titel", "Projekte Titel", "pr_titel", "theme-options", "section");
  795. register_setting("section", "pr_titel");
  796. add_settings_field("pr_extra", "Projekte extra Text", "pr_extra", "theme-options", "section");
  797. register_setting("section", "pr_extra");
  798. add_settings_field("separator-b", "", "separator", "theme-options", "section");
  799. add_settings_field("kontakt_daten", "Kontaktdaten (1. Spalte im Footer)", "kontakt_daten", "theme-options", "section");
  800. register_setting("section", "kontakt_daten");
  801. add_settings_field("zweite_spalte", "2. Spalte im Footer", "zweite_spalte", "theme-options", "section");
  802. register_setting("section", "zweite_spalte");
  803. add_settings_field("dritte_spalte", "3. Spalte im Footer", "dritte_spalte", "theme-options", "section");
  804. register_setting("section", "dritte_spalte");
  805. // add_settings_field("vierte_spalte", "4. Spalte im Footer", "vierte_spalte", "theme-options", "section");
  806. // register_setting("section", "vierte_spalte");
  807. /*
  808. add_settings_section("section", "All Settings", null, "theme-options");
  809. add_settings_field("twitter_url", "Twitter Profile Url", "display_twitter_element", "theme-options", "section");
  810. add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_element", "theme-options", "section");
  811. register_setting("section", "twitter_url");
  812. register_setting("section", "facebook_url"); */
  813. }
  814. add_action("admin_init", "display_theme_panel_fields");
  815. function encode_email_shortcode($atts, $content = null) {
  816. for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
  817. return '<a class="encoded-email" href="mailto:' . $encodedmail . '"><i class="fa fa-envelope" aria-hidden="true"></i></a>';
  818. }
  819. add_shortcode('email', 'encode_email_shortcode');
  820. /* DON'T DELETE THIS CLOSING TAG */ ?>