vamtam-blog.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. /**
  3. * @class VamtamBlogModule
  4. */
  5. class VamtamBlogModule extends FLBuilderModule {
  6. /**
  7. * @method __construct
  8. */
  9. public function __construct() {
  10. $path = trailingslashit( 'modules/' . basename( dirname( __FILE__ ) ) );
  11. parent::__construct(array(
  12. 'name' => __( 'Blog', 'vamtam-elements-b' ),
  13. 'description' => __( 'Display your WordPress posts.', 'vamtam-elements-b' ),
  14. 'category' => __( 'VamTam Modules', 'vamtam-elements-b' ),
  15. 'partial_refresh' => true,
  16. 'dir' => VAMTAMEL_B_DIR . $path,
  17. 'url' => VAMTAMEL_B_URL . $path,
  18. ));
  19. }
  20. /**
  21. * @method enqueue_scripts
  22. */
  23. public function enqueue_scripts() {
  24. if ( FLBuilderModel::is_builder_active() ) {
  25. $this->add_js( 'cubeportfolio' );
  26. $this->add_css( 'cubeportfolio' );
  27. }
  28. }
  29. /**
  30. * Renders the schema structured data for the current
  31. * post in the loop.
  32. *
  33. * @since 1.7.4
  34. * @return void
  35. */
  36. static public function schema_meta() {
  37. global $vamtam_theme;
  38. // General Schema Meta
  39. echo '<meta itemprop="datePublished" content="' . esc_attr( get_the_time( 'Y-m-d' ) ) . '" />';
  40. echo '<meta itemprop="dateModified" content="' . esc_attr( get_the_modified_date( 'Y-m-d' ) ) . '" />';
  41. // Publisher Schema Meta
  42. echo '<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">';
  43. echo '<meta itemprop="name" content="' . esc_attr( get_bloginfo( 'name' ) ) . '">';
  44. echo '<meta itemprop="url" content="' . esc_attr( get_home_url() ) . '">';
  45. if ( isset( $vamtam_theme['header-logo-type'] ) && 'image' === $vamtam_theme['header-logo-type'] ) {
  46. echo '<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">';
  47. echo '<meta itemprop="url" content="' . esc_url( $vamtam_theme['custom-header-logo'] ) . '">';
  48. echo '</div>';
  49. }
  50. echo '</div>';
  51. // Author Schema Meta
  52. echo '<div itemscope itemprop="author" itemtype="http://schema.org/Person">';
  53. echo '<meta itemprop="url" content="' . esc_attr( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" />';
  54. echo '<meta itemprop="name" content="' . esc_attr( get_the_author_meta( 'display_name', get_the_author_meta( 'ID' ) ) ) . '" />';
  55. echo '</div>';
  56. // Image Schema Meta
  57. if ( has_post_thumbnail() ) {
  58. $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
  59. if ( is_array( $image ) ) {
  60. echo '<div itemscope itemprop="image" itemtype="http://schema.org/ImageObject">';
  61. echo '<meta itemprop="url" content="' . esc_url( $image[0] ) . '" />';
  62. echo '<meta itemprop="width" content="' . intval( $image[1] ) . '" />';
  63. echo '<meta itemprop="height" content="' . intval( $image[2] ) . '" />';
  64. echo '</div>';
  65. }
  66. }
  67. // Comment Schema Meta
  68. echo '<div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">';
  69. echo '<meta itemprop="interactionType" content="http://schema.org/CommentAction" />';
  70. echo '<meta itemprop="userInteractionCount" content="' . esc_attr( wp_count_comments( get_the_ID() )->approved ) . '" />';
  71. echo '</div>';
  72. }
  73. /**
  74. * Renders the schema itemtype for the current
  75. * post in the loop.
  76. *
  77. * @since 1.7.4
  78. * @return void
  79. */
  80. static public function schema_itemtype() {
  81. global $post;
  82. if ( ! is_object( $post ) || ! isset( $post->post_type ) || 'post' !== $post->post_type ) {
  83. echo 'http://schema.org/CreativeWork';
  84. } else {
  85. echo 'http://schema.org/BlogPosting';
  86. }
  87. }
  88. }
  89. /**
  90. * Register the module and its form settings.
  91. */
  92. FLBuilder::register_module('VamtamBlogModule', array(
  93. 'layout' => array(
  94. 'title' => __( 'Layout', 'vamtam-elements-b' ),
  95. 'sections' => array(
  96. 'general' => array(
  97. 'title' => '',
  98. 'fields' => array(
  99. 'layout' => array(
  100. 'type' => 'select',
  101. 'label' => __( 'Layout', 'vamtam-elements-b' ),
  102. 'default' => 'small',
  103. 'options' => array(
  104. 'normal' => esc_html__( 'Big Images', 'vamtam-elements-b' ),
  105. 'small' => esc_html__( 'Small Images - Normal', 'vamtam-elements-b' ),
  106. 'scroll-x' => esc_html__( 'Small Images - Scrollable', 'vamtam-elements-b' ),
  107. 'mosaic' => esc_html__( 'Small Images - Mosaic (Masonry)', 'vamtam-elements-b' ),
  108. ),
  109. 'toggle' => array(
  110. 'normal' => array(
  111. 'fields' => array( 'pagination' ),
  112. ),
  113. 'small' => array(
  114. 'sections' => array( 'grid' ),
  115. 'fields' => array( 'pagination', 'show_title' ),
  116. ),
  117. 'scroll-x' => array(
  118. 'sections' => array( 'grid' ),
  119. 'fields' => array( 'show_title' ),
  120. ),
  121. 'mosaic' => array(
  122. 'sections' => array( 'grid' ),
  123. 'fields' => array( 'pagination', 'show_title' ),
  124. ),
  125. ),
  126. ),
  127. 'pagination' => array(
  128. 'type' => 'select',
  129. 'label' => __( 'Pagination', 'vamtam-elements-b' ),
  130. 'default' => 'true',
  131. 'options' => array(
  132. 'true' => esc_html__( 'On', 'vamtam-elements-b' ),
  133. 'false' => esc_html__( 'Off', 'vamtam-elements-b' ),
  134. ),
  135. ),
  136. 'posts_per_page' => array(
  137. 'type' => 'unit',
  138. 'label' => esc_html__( 'Posts Per Page', 'vamtam-elements-b' ),
  139. 'default' => 10,
  140. 'min' => -1,
  141. 'max' => 100,
  142. ),
  143. ),
  144. ),
  145. 'grid' => array(
  146. 'title' => __( 'Grid', 'vamtam-elements-b' ),
  147. 'fields' => array(
  148. 'columns' => array(
  149. 'type' => 'unit',
  150. 'label' => esc_html__( 'Columns', 'vamtam-elements-b' ),
  151. 'default' => 3,
  152. 'min' => 2,
  153. 'max' => 4,
  154. ),
  155. 'gap' => array(
  156. 'type' => 'select',
  157. 'label' => esc_html__( 'Gap Between Items', 'vamtam-elements-b' ),
  158. 'default' => 'true',
  159. 'options' => array(
  160. 'true' => esc_html__( 'On', 'vamtam-elements-b' ),
  161. 'false' => esc_html__( 'Off', 'vamtam-elements-b' ),
  162. ),
  163. ),
  164. ),
  165. ),
  166. 'content' => array(
  167. 'title' => __( 'Content', 'vamtam-elements-b' ),
  168. 'fields' => array(
  169. 'show_title' => array(
  170. 'type' => 'select',
  171. 'label' => __( 'Post Title', 'vamtam-elements-b' ),
  172. 'default' => '1',
  173. 'options' => array(
  174. '1' => __( 'Show', 'vamtam-elements-b' ),
  175. '0' => __( 'Hide', 'vamtam-elements-b' ),
  176. ),
  177. ),
  178. 'show_content' => array(
  179. 'type' => 'select',
  180. 'label' => __( 'Post Content', 'vamtam-elements-b' ),
  181. 'default' => '1',
  182. 'options' => array(
  183. '1' => __( 'Show', 'vamtam-elements-b' ),
  184. '0' => __( 'Hide', 'vamtam-elements-b' ),
  185. ),
  186. ),
  187. 'show_media' => array(
  188. 'type' => 'select',
  189. 'label' => __( 'Show Media (if available)', 'vamtam-elements-b' ),
  190. 'default' => '1',
  191. 'options' => array(
  192. '1' => __( 'Show', 'vamtam-elements-b' ),
  193. '0' => __( 'Hide', 'vamtam-elements-b' ),
  194. ),
  195. ),
  196. ),
  197. ),
  198. ),
  199. ),
  200. 'content' => array(
  201. 'title' => __( 'Query', 'vamtam-elements-b' ),
  202. 'file' => FL_BUILDER_DIR . 'includes/loop-settings.php',
  203. ),
  204. ));