浏览代码

thunbs, testimonials, options

Juan Carlos 5 年之前
父节点
当前提交
47702f6127
共有 3 个文件被更改,包括 208 次插入104 次删除
  1. 2 2
      footer.php
  2. 144 62
      functions.php
  3. 62 40
      index.php

+ 2 - 2
footer.php

@@ -12,8 +12,8 @@
 
 
             <?php
-             $options = get_option('rl_theme_options');
-             echo $options['kontakt'];
+             $options = get_option('kontakt_daten');
+             echo $options;
             ?>
 
 

+ 144 - 62
functions.php

@@ -433,6 +433,50 @@ function clients() {
    register_post_type( 'clients', $args );
 }
 
+
+add_action('init', 'testimonials', 0);
+function testimonials() {
+   $labels = array(
+      'name' => _x('testimonials', 'Post Type General Name', 'theme'),
+      'singular_name' => _x('Testimonial', 'Post Type Singular Name', 'theme'),
+      'menu_name' => __('testimonials', 'theme'),
+      'name_admin_bar' => __('testimonials', 'theme'),
+      'parent_item_colon' => __('Parent testimonials:', 'theme'),
+      'all_items' => __('All testimonials', 'theme'),
+      'add_new_item' => __('Add New testimonial', 'theme'),
+      'add_new' => __('Add New', 'theme'),
+      'new_item' => __('New testimonial', 'theme'),
+      'edit_item' => __('Edit testimonial', 'theme'),
+      'update_item' => __('Update testimonial', 'theme'),
+      'view_item' => __('View testimonials', 'theme'),
+      'search_items' => __('Search testimonials', 'theme'),
+      'not_found' => __('Not found', 'theme'),
+      'not_found_in_trash' => __('Not found in Trash', 'theme'),
+   );
+
+   $args = array(
+      'label' => __('testimonials', 'theme'),
+      'labels' => $labels,
+      'description' => __('Team', 'theme'),
+      'supports' => array('title', 'thumbnail'),
+      //'taxonomies' => array('category', 'post_tag'),
+      'hierarchical' => false,
+      'public' => true,
+      'show_ui' => true,
+      'show_in_menu' => true,
+      'menu_position' => 5,
+      'show_in_admin_bar' => true,
+      'show_in_nav_menus' => true,
+      'can_export' => true,
+      'has_archive' => true,
+      'exclude_from_search' => false,
+      'publicly_queryable' => true,
+      'capability_type' => 'page',
+      'menu_icon' => 'dashicons-smiley',
+   );
+   register_post_type( 'testimonials', $args );
+}
+
 add_action("admin_init", "admin_init");
 
 function admin_init(){
@@ -445,10 +489,13 @@ function admin_init(){
   // Baugruppen
   add_meta_box("baugruppe-link",        "Link", "baugruppe_link", "baugruppen", "normal", "low");
   // Baugruppen
-  add_meta_box("client-link",        "Link", "client_link", "clients", "normal", "low");
+  add_meta_box("client-link",           "Link", "client_link", "clients", "normal", "low");
+  // Testimonials
+  add_meta_box("bericht-text",           "Text",  "testimonial_text",  "testimonials", "normal", "low");
+  add_meta_box("bericht-autor",          "Autor", "testimonial_autor", "testimonials", "normal", "low");
+  add_meta_box("bericht-link",           "Link",  "testimonial_link",  "testimonials", "normal", "low");
 }
 
-
 function mitarbeiter_email(){
   global $post;
   $custom = get_post_custom($post->ID);
@@ -499,7 +546,6 @@ function baugruppe_link(){
   <?php
 }
 
-
 function client_link(){
   global $post;
   $custom = get_post_custom($post->ID);
@@ -510,24 +556,62 @@ function client_link(){
   <?php
 }
 
+function testimonial_text(){
+  global $post;
+  $custom = get_post_custom($post->ID);
+  $testimonial_text = $custom["testimonial_text"][0];
+  ?>
+  <label>Text:</label>
+  <input name="testimonial_text" value="<?php echo $testimonial_text; ?>" />
+  <?php
+}
+
+function testimonial_autor(){
+  global $post;
+  $custom = get_post_custom($post->ID);
+  $testimonial_autor = $custom["testimonial_autor"][0];
+  ?>
+  <label>Author:</label>
+  <input name="testimonial_autor" value="<?php echo $testimonial_autor; ?>" />
+  <?php
+}
+
+function testimonial_link(){
+  global $post;
+  $custom = get_post_custom($post->ID);
+  $testimonial_link = $custom["testimonial_link"][0];
+  ?>
+  <label>Author:</label>
+  <input name="testimonial_link" value="<?php echo $testimonial_link; ?>" />
+  <?php
+}
+
+
+
+
 add_action('save_post', 'save_details');
 
 function save_details(){
   global $post;
   // mitarbeiter
   update_post_meta($post->ID, "mitarbeiter_position", $_POST["mitarbeiter_position"]);
-  update_post_meta($post->ID, "mitarbeiter_email", $_POST["mitarbeiter_email"]);
+  update_post_meta($post->ID, "mitarbeiter_email",    $_POST["mitarbeiter_email"]);
   // Projekte
   update_post_meta($post->ID, "projekt_beschreibung", $_POST["projekt_beschreibung"]);
-  update_post_meta($post->ID, "projekt_link", $_POST["projekt_link"]);
+  update_post_meta($post->ID, "projekt_link",         $_POST["projekt_link"]);
   // baugruppen
-  update_post_meta($post->ID, "baugruppe_link", $_POST["baugruppe_link"]);
+  update_post_meta($post->ID, "baugruppe_link",    $_POST["baugruppe_link"]);
+  // clients
+  update_post_meta($post->ID, "client_link",       $_POST["client_link"]);
   // clients
-  update_post_meta($post->ID, "client_link", $_POST["client_link"]);
+  update_post_meta($post->ID, "testimonial_text",  $_POST["testimonial_text"]);
+  update_post_meta($post->ID, "testimonial_autor", $_POST["testimonial_autor"]);
+  update_post_meta($post->ID, "testimonial_link",  $_POST["testimonial_link"]);
 }
 
 
-add_image_size( 'projekt_thumb', 355, 236, true);
+add_image_size( 'general_thumb', 355, 236, true);
+add_image_size( 'mitarbeiter_thumb', 255, 255, true);
 
 /*
 
@@ -542,70 +626,68 @@ Testimonials
 
 
 
+function theme_settings_page()
+{
+    ?>
+	    <div class="wrap">
+	    <h1>Theme Panel</h1>
+	    <form method="post" action="options.php">
+	        <?php
+	            settings_fields("section");
+	            do_settings_sections("theme-options");
+	            submit_button();
+	        ?>
+	    </form>
+		</div>
+	<?php
+}
 
-/* ------------------ */
-/* theme options page */
-/* ------------------ */
-/* https://blog.kulturbanause.de/2011/11/theme-options-page-fur-wordpress-erstellen/ */
 
-add_action( 'admin_init', 'theme_options_init' );
-add_action( 'admin_menu', 'theme_options_add_page' );
 
-// Einstellungen registrieren (http://codex.wordpress.org/Function_Reference/register_setting)
-function theme_options_init(){
-	register_setting( 'rl_options', 'rl_theme_options', 'rl_validate_options' );
+function add_theme_menu_item()
+{
+	add_menu_page("Text blocks", "Text blocks", "manage_options", "theme-panel", "theme_settings_page", null, 99);
 }
 
-// Seite in der Dashboard-Navigation erstellen
-function theme_options_add_page() {
-	add_theme_page('Optionen', 'Optionen', 'edit_theme_options', 'theme-optionen', 'rl_theme_options_page' ); // Seitentitel, Titel in der Navi, Berechtigung zum Editieren (http://codex.wordpress.org/Roles_and_Capabilities) , Slug, Funktion
-}
+add_action("admin_menu", "add_theme_menu_item");
 
-// Optionen-Seite erstellen
-function rl_theme_options_page() {
-global $select_options, $radio_options;
-if ( ! isset( $_REQUEST['settings-updated'] ) )
-	$_REQUEST['settings-updated'] = false; ?>
-
-<div class="wrap">
-<?php screen_icon(); ?><h2>Theme-Optionen für <?php bloginfo('name'); ?></h2>
-
-<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
-<div class="updated fade">
-	<p><strong>Einstellungen gespeichert!</strong></p>
-</div>
-<?php endif; ?>
-
-  <form method="post" action="options.php">
-	<?php settings_fields( 'rl_options' ); ?>
-    <?php $options = get_option( 'rl_theme_options' ); ?>
-
-    <table class="form-table">
-
-      <tr valign="top">
-        <th scope="row">Google Analytics</th>
-        <td><textarea id="rl_theme_options[kontakt]" class="large-text" cols="50" rows="10" name="rl_theme_options[kontakt]"><?php echo esc_textarea( $options['kontakt'] ); ?></textarea></td>
-      </tr>
-    </table>
-
-    <!-- submit -->
-    <p class="submit"><input type="submit" class="button-primary" value="Einstellungen speichern" /></p>
-  </form>
-</div>
-<?php }
-
-// Strip HTML-Code:
-// Hier kann definiert werden, ob HTML-Code in einem Eingabefeld
-// automatisch entfernt werden soll. Soll beispielsweise im
-// Copyright-Feld KEIN HTML-Code erlaubt werden, kommentiert die Zeile
-// unten wieder ein. http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses
-function rl_validate_options( $input ) {
-	// $input['copyright'] = wp_filter_nohtml_kses( $input['copyright'] );
-	return $input;
+
+function kontakt_daten()
+{
+	?>
+    	<textarea type="text" rows="10" cols="30" name="kontakt_daten" id="kontakt_daten">
+        <?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> -->'); ?>
+      </textarea>
+    <?php
 }
 
+/*
+function display_facebook_element()
+{
+	?>
+    	<input type="text" name="facebook_url" id="facebook_url" value="<?php echo get_option('facebook_url'); ?>" />
+    <?php
+}*/
 
+function display_theme_panel_fields()
+{
+	add_settings_section("section", "All Settings", null, "theme-options");
+
+	add_settings_field("kontakt_daten", "Contact data", "kontakt_daten", "theme-options", "section");
+
+    register_setting("section", "kontakt_daten");
+/*
+    add_settings_section("section", "All Settings", null, "theme-options");
+
+  	add_settings_field("twitter_url", "Twitter Profile Url", "display_twitter_element", "theme-options", "section");
+      add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_element", "theme-options", "section");
+
+      register_setting("section", "twitter_url");
+      register_setting("section", "facebook_url");    */
+
+}
 
+add_action("admin_init", "display_theme_panel_fields");
 
 
 

+ 62 - 40
index.php

@@ -156,7 +156,7 @@
                   <!-- Team Item Starts -->
                   <div class="col-lg-3 col-md-6 col-xs-12">
                   <figure>
-                  <img src="<?php echo get_the_post_thumbnail_url($posts->post->ID, array( "width" => 255, "height" => 255 )); ?>" alt="<?php the_title(); ?>">
+                  <img src="<?php echo get_the_post_thumbnail_url($posts->post->ID, 'general_thumb' ); ?>" alt="<?php the_title(); ?>">
                     <div class="image-overlay">
                       <div class="overlay-text text-center">
                         <div class="info-text">
@@ -250,7 +250,7 @@
       <li class="col-md-3 col-sm-6 project">
         <figure>
           <div class="hovereffect round-pic" style="<?php echo $divmargin ?>">
-            <img src="<?php echo get_the_post_thumbnail_url($posts->post->ID, array( "width" => 255, "height" => 255 )); ?>" alt="<?php the_title(); ?>">
+            <img src="<?php echo get_the_post_thumbnail_url($posts->post->ID, 'general_thumb' ); ?>" alt="<?php the_title(); ?>">
             <div class="overlay">
               <div class="iocns">
                 <a class="left-link" href="<?php echo get_post_meta($posts->post->ID, 'baugruppe_link', true); ?>"><i class="fa fa-link"></i></a>
@@ -329,7 +329,7 @@
         <li class="col-md-2 col-sm-6 project">
           <figure>
             <div class="hovereffect round-pic">
-              <img src="<?php echo get_the_post_thumbnail_url($posts->post->ID, array( "width" => 255, "height" => 255 )); ?>" alt="<?php the_title(); ?>">
+              <img src="<?php echo get_the_post_thumbnail_url($posts->post->ID, 'general_thumb' ); ?>" alt="<?php the_title(); ?>">
               <div class="overlay">
                 <div class="iocns">
                   <a class="left-link" href="<?php echo get_post_meta($posts->post->ID, 'client_link', true); ?>"><i class="fa fa-link"></i></a>
@@ -410,6 +410,62 @@
         </div>
 
 
+
+
+        <?php
+
+          $args = array(
+              'post_type' => 'testimonials',
+              'post_status' => 'publish',
+              'posts_per_page' => 100
+          );
+          $posts = new WP_Query($args);
+          $counter = 1;
+
+
+          while ($posts -> have_posts()) {
+              $posts->the_post();
+
+              ?>
+
+              <div id="single-testimonial-item" class="owl-carousel">
+                <!-- Single testimonial Item -->
+                <div class="item">
+                  <div class="row justify-content-md-center">
+                    <div class="col-lg-8 col-md-12 col-xs-12 col-md-auto">
+                      <div class="testimonial-inner text-md-center">
+                        <blockquote>
+                          <?php echo get_post_meta($posts->post->ID, 'testimonial_text', true); ?>
+                        </blockquote>
+                        <div class="testimonial-images">
+                          <img class="img-circle text-md-center" src="<?php echo get_the_post_thumbnail_url($posts->post->ID, 'general_thumb' ); ?>" alt="">
+                        </div>
+                        <div class="testimonial-footer">
+                          <i class="fa fa-user"></i>
+                          <a href="<?php echo get_post_meta($posts->post->ID, 'testimonial_link', true); ?>"> <?php echo get_post_meta($posts->post->ID, 'testimonial_autor', true); ?></a>
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                </div>
+
+            <?php if ($counter && $counter % 6 == 0): ?>
+
+              </ul>
+              <ul class="row portfolio list-unstyled justify-content-center" id="grid-clients">
+
+            <?php endif;
+
+            $counter++;
+
+          } //  while ( $posts -> have_posts() )
+          wp_reset_postdata();
+
+
+          ?>
+
+
+
         <div id="single-testimonial-item" class="owl-carousel">
           <!-- Single testimonial Item -->
           <div class="item">
@@ -431,44 +487,10 @@
             </div>
           </div>
 
-          <!-- Single testimonial Item -->
-          <div class="item">
-            <div class="row justify-content-md-center">
-              <div class="col-lg-8 col-md-12 col-xs-12 col-md-auto">
-                <div class="testimonial-inner text-md-center">
-                  <blockquote>
-                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id ipsam, non ut molestiae rerum praesentium repellat debitis iure reiciendis, eius culpa beatae commodi facere ad numquam. Quisquam dignissimos similique sunt iure fugit, omnis vel cupiditate repellendus magni nihil molestiae quam, delectus
-                  </blockquote>
-                  <div class="testimonial-images">
-                    <img class="img-circle text-md-center" src="<?php echo get_template_directory_uri(); ?>/img/testimonial/img2.jpg" alt="">
-                  </div>
-                  <div class="testimonial-footer">
-                    <i class="fa fa-user"></i> Jeniffer
-                    <a href="#"> GrayGrids</a>
-                  </div>
-                </div>
-              </div>
-            </div>
-          </div>
 
-          <!-- Single testimonial Item -->
-          <div class="item">
-            <div class="row justify-content-md-center">
-              <div class="col-lg-8 col-md-12 col-xs-12 col-md-auto">
-                <div class="testimonial-inner text-md-center">
-                  <blockquote>
-                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id ipsam, non ut molestiae rerum praesentium repellat debitis iure reiciendis, eius culpa beatae commodi facere ad numquam. Quisquam dignissimos similique sunt iure fugit, omnis vel cupiditate repellendus magni nihil molestiae quam, delectus
-                  </blockquote>
-                  <div class="testimonial-images">
-                    <img class="img-circle text-md-center" src="<?php echo get_template_directory_uri(); ?>/img/testimonial/img3.jpg" alt="">
-                  </div>
-                  <div class="testimonial-footer">
-                    <i class="fa fa-user"></i> Elon Musk<a href="#"> Tesla</a>
-                  </div>
-                </div>
-              </div>
-            </div>
-          </div>
+
+
+
         </div>
       </div>
     </div>