Explorar el Código

:sparkles: #18 | added ability to sticky posts in editor | added api key for stick posts

tags/0.9.0
j hace 5 años
padre
commit
f30f097394

+ 8
- 5
plugins/cia-endpoints/includes/class.make-endpoint.php Ver fichero

@@ -114,25 +114,28 @@ class Make_Endpoint_For extends WP_REST_Controller {
114 114
             $filtered[hero] = get_post_meta( $item->ID, 'hero_header', true );
115 115
 
116 116
             // $filtered[relatedto] = p2p_related_to( $item->ID, $item->post_type );
117
-
117
+            
118 118
             $collection[$item->ID] = $filtered;
119 119
         }
120 120
         wp_reset_postdata();
121
-
121
+        
122 122
         return $collection;
123 123
     }
124 124
     public function prepare_all_items_for_response( $args ) {
125 125
         $collection = array();
126
-
126
+        
127 127
         // https://developer.wordpress.org/reference/functions/get_posts/
128 128
         foreach( get_posts($args) as $item ) {
129 129
             $filtered = default_post_format( $item );
130
-
130
+            
131 131
             // Find all image info
132 132
             $filtered[attached] = $this->_getAttachments( $item, $filtered[galleries] );
133
-
133
+            
134 134
             // For your hero URL
135 135
             $filtered[hero] = get_post_meta( $item->ID, 'hero_header', true );
136
+            
137
+            // Sticky
138
+            $filtered[sticky] = get_post_meta( $item->ID, 'is_sticky', true );
136 139
 
137 140
             // $filtered[relatedto] = p2p_related_to( $item->ID, $item->post_type );
138 141
 

+ 0
- 1
plugins/cia-endpoints/includes/formats.php Ver fichero

@@ -20,7 +20,6 @@ function default_post_format( $item ) {
20 20
     $filtered[featured] = get_the_post_thumbnail_url($item);
21 21
 
22 22
 
23
-
24 23
     // Materials + type endpoints
25 24
     // if($item->post_type === 'artist' || $item->post_type === 'event' || $item->post_type === 'exhibition') {
26 25
     $posts_with_type = ['artist', 'exhbition', 'event'];

+ 1
- 0
plugins/cia-post-types/cia-post-types.php Ver fichero

@@ -83,6 +83,7 @@ add_action('init', 'create_types_taxonomy');
83 83
  * Create CMB Metaboxes
84 84
  */
85 85
 add_action( 'cmb2_admin_init', 'cmb2_hero_metaboxes' );
86
+add_action( 'cmb2_admin_init', 'cmb2_sticky_metaboxes' );
86 87
 add_action( 'cmb2_admin_init', 'cmb2_artist_sort_metaboxes' );
87 88
 add_action( 'cmb2_admin_init', 'cmb2_event_date_metaboxes' );
88 89
 add_action( 'cmb2_admin_init', 'cmb2_exhibition_date_metaboxes' );

+ 21
- 0
plugins/cia-post-types/includes/custom-metaboxes.php Ver fichero

@@ -54,6 +54,27 @@
54 54
         ) );
55 55
     }
56 56
 
57
+    function cmb2_sticky_metaboxes() {
58
+
59
+        /**
60
+         * Initiate the metabox
61
+         */
62
+        $cmb = new_cmb2_box( array(
63
+            'id'            => 'stick_metabox',
64
+            'title'         => __( 'Sticky Post', 'cmb2' ),
65
+            'object_types'  => array( 'artist', 'event', 'exhibition', 'episode', 'page', 'post' ), // Post type
66
+            'show_in_rest'  => WP_REST_Server::READABLE
67
+        ) );
68
+
69
+        // URL text field
70
+        $cmb->add_field( array(
71
+            'name'             => __( 'Make sticky?', 'cmb2' ),
72
+            'desc'             => __( 'Check to stick this post on the homepage', 'cmb2' ),
73
+            'id'               => 'is_sticky',
74
+            'type'             => 'checkbox'
75
+        ) );
76
+    }
77
+
57 78
     function cmb2_artist_sort_metaboxes() {
58 79
         $cmb = new_cmb2_box( array(
59 80
             'id'            => 'artist_sort_metabox',

Loading…
Cancelar
Guardar