]> _ Git - ccv-wordpress.git/commitdiff
WIP #3053
authorStephen Cameron <stephen@cubedesigners.com>
Tue, 17 Dec 2019 19:49:41 +0000 (20:49 +0100)
committerStephen Cameron <stephen@cubedesigners.com>
Tue, 17 Dec 2019 19:49:41 +0000 (20:49 +0100)
wp-content/mu-plugins/cube/src/CPT/Person.php [new file with mode: 0644]
wp-content/mu-plugins/cube/src/CPT/ScientificNews.php [new file with mode: 0644]
wp-content/mu-plugins/cube/src/Init.php
wp-content/themes/CCV/resources/views/partials/content-single-scientific_news.blade.php [new file with mode: 0644]

diff --git a/wp-content/mu-plugins/cube/src/CPT/Person.php b/wp-content/mu-plugins/cube/src/CPT/Person.php
new file mode 100644 (file)
index 0000000..d6748b6
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+namespace Cube\CPT;
+
+class Person {
+
+    public function register() {
+
+        // Wait for TypeRocket to load before adding post type
+        add_action('typerocket_loaded', function() {
+            $person = \tr_post_type('Person', 'People')
+                ->setIcon('users')
+                ->setArgument('publicly_queryable', false) // No public page, just used as part of other posts
+                ->setArgument('supports', ['title']) // No editor for this post type
+                ->setTitlePlaceholder('Enter full name here')
+                ->setTitleForm(function() {
+                    $form = \tr_form();
+                    echo $form->image('Photo');
+                });
+        });
+    }
+
+}
diff --git a/wp-content/mu-plugins/cube/src/CPT/ScientificNews.php b/wp-content/mu-plugins/cube/src/CPT/ScientificNews.php
new file mode 100644 (file)
index 0000000..a5c9957
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+namespace Cube\CPT;
+
+class ScientificNews {
+
+    public function register() {
+
+        // Wait for TypeRocket to load before adding post type
+        add_action('typerocket_loaded', function() {
+            $science_news = \tr_post_type('Scientific News')
+                ->setIcon('flask')
+                ->setEditorForm(function() {
+                    $form = \tr_form();
+                    echo $form->gallery('Images');
+                    echo $form->search('Published By')->setPostType('person');
+                });
+        });
+    }
+
+}
index e93ae2617973adfe91278a13d4487a2b5399676a..3762fdf3042e556d55bd00137684795927104eb8 100644 (file)
@@ -15,6 +15,8 @@ final class Init { // Marked as final because this class should never be extende
         return [
             Common\Setup::class,
             Elementor\Setup::class,
+            CPT\Person::class,
+            CPT\ScientificNews::class,
         ];
     }
 
diff --git a/wp-content/themes/CCV/resources/views/partials/content-single-scientific_news.blade.php b/wp-content/themes/CCV/resources/views/partials/content-single-scientific_news.blade.php
new file mode 100644 (file)
index 0000000..9e9ca50
--- /dev/null
@@ -0,0 +1,40 @@
+<article @php(post_class('container px-2v pb-2v flex items-start sm:flex-wrap sm:flex-col-reverse'))>
+
+  <header class="mr-2v mb-2v">
+
+    <div class="pb-8">
+      <em>{{ __('PubliĆ© par') }}</em>
+      <br/>
+      {{-- Todo: get linked post type data for user from published_by ID --}}
+      <strong>{{ tr_posts_field('published_by') }}</strong>
+    </div>
+
+    @foreach(tr_posts_field('images') as $image)
+      <div class="post-featured-image mb-4" style="background-image: url({{ wp_get_attachment_image_url($image, 'full') }})">
+        <div class="post-featured-image-sizer">{{-- Just here as a proportional sizer thanks to the padding --}}</div>
+      </div>
+    @endforeach
+
+  </header>
+
+  <div class="entry-content mb-2v">
+    <h1 class="plain my-4 h2">
+      {!! $title !!}
+    </h1>
+
+    @php(the_content())
+
+    <p class="mt-6">
+      <a class="uppercase text-pink inline-flex items-center" href="<?= get_post_type_archive_link('post') ?>">
+        @svg('arrow', 'h-3 mr-2 fill-current')
+        <?= __('Retour') ?>
+      </a>
+    </p>
+  </div>
+
+  {{--
+  <footer>
+    {!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!}
+  </footer>
+  --}}
+</article>