PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/themes/nonus/theme/types/portfolio.php

https://github.com/alniko009/magic
PHP | 174 lines | 144 code | 18 blank | 12 comment | 6 complexity | 169f8c4368a33a89d1b6a54737225fba MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. require_once CT_THEME_LIB_DIR . '/types/ctPortfolioTypeBase.class.php';
  3. /**
  4. * Custom type - portfolio
  5. */
  6. class ctPortfolioType extends ctPortfolioTypeBase {
  7. /**
  8. * Adds meta box
  9. */
  10. public function addMetaBox() {
  11. parent::addMetaBox();
  12. add_meta_box("portfolio-template-meta", __("Template settings", 'ct_theme'), array($this, "portfolioTemplateMeta"), "portfolio", "normal", "high");
  13. }
  14. /**
  15. * Draw s portfolio meta
  16. */
  17. public function portfolioMeta() {
  18. global $post;
  19. $custom = get_post_custom($post->ID);
  20. $client = isset($custom["client"][0]) ? $custom["client"][0] : "";
  21. $client_icon = isset($custom["client_icon"][0]) ? ($custom["client_icon"][0] ? $custom["client_icon"][0] : "batch user-2") : '';
  22. $date = isset($custom["date"][0]) ? $custom["date"][0] : "";
  23. $date_icon = isset($custom["date_icon"][0]) ? ($custom["date_icon"][0] ? $custom["date_icon"][0] : "icon-calendar") : "";
  24. $venue = isset($custom["venue"][0]) ? $custom["venue"][0] : "";
  25. $venue_icon = isset($custom["venue_icon"][0]) ? ($custom["venue_icon"][0] ? $custom["venue_icon"][0] : "icon-map-marker") : "";
  26. $external_url = isset($custom["external_url"][0]) ? $custom["external_url"][0] : "";
  27. $external_label = isset($custom["external_label"][0]) ? $custom["external_label"][0] : "";
  28. $video = isset($custom["video"][0]) ? $custom["video"][0] : "";
  29. $displayMethod = isset($custom['display_method'][0]) ? $custom['display_method'][0] : 'image';
  30. $revolution_slider = isset($custom['revolution_slider'][0]) ? $custom['revolution_slider'][0] : '';
  31. if ($supportsRevolutionSlider = function_exists('rev_slider_shortcode')) {
  32. global $wpdb;
  33. $slides = $wpdb->get_results("SELECT * FROM wp_revslider_sliders");
  34. }
  35. ?>
  36. <p>
  37. <label for="client"><?php _e('Client', 'ct_theme')?>: </label>
  38. <input id="client" class="regular-text" name="client" value="<?php echo $client; ?>"/>
  39. <p class="howto"><?php _e("Information about client", 'ct_theme')?></p>
  40. <p>
  41. <label for="client_icon"><?php _e('Client icon', 'ct_theme')?>: </label>
  42. <input id="client_icon" class="regular-text" name="client_icon" value="<?php echo $client_icon; ?>"/>
  43. <?php $clientIcons = sprintf(__(" View %s and enter icon name ex. user", 'ct_theme'), '<a target="_blank" id="open_client_icon' . '" href="' . CT_THEME_ASSETS . '/shortcode/batch/index.html' . '">' . __('available icons', 'ct_theme') . '</a>')?>
  44. <p class="howto"><?php echo __("Link to icon representation of the client field.", 'ct_theme') . $clientIcons?></p>
  45. <p>
  46. <label for="date"><?php _e('Date', 'ct_theme')?>: </label>
  47. <input id="date" class="regular-text" name="date" value="<?php echo $date; ?>"/>
  48. <p class="howto"><?php _e("Information about date", 'ct_theme')?></p>
  49. <p>
  50. <label for="date_icon"><?php _e('Date icon', 'ct_theme')?>: </label>
  51. <input id="date_icon" class="regular-text" name="date_icon" value="<?php echo $date_icon; ?>"/>
  52. <?php $dateIcons = sprintf(__(" View %s and enter icon name ex. user", 'ct_theme'), '<a target="_blank" id="open_date_icon' . '" href="' . CT_THEME_ASSETS . '/shortcode/batch/index.html' . '">' . __('available icons', 'ct_theme') . '</a>')?>
  53. <p class="howto"><?php echo __("Link to icon representation of the date field", 'ct_theme') . $dateIcons?></p>
  54. <p>
  55. <label for="venue"><?php _e('Venue', 'ct_theme')?>: </label>
  56. <input id="venue" class="regular-text" name="venue" value="<?php echo $venue; ?>"/>
  57. <p class="howto"><?php _e("Information about venue", 'ct_theme')?></p>
  58. <p>
  59. <label for="venue_icon"><?php _e('Venue icon', 'ct_theme')?>: </label>
  60. <input id="venue_icon" class="regular-text" name="venue_icon" value="<?php echo $venue_icon; ?>"/>
  61. <?php $venueIcons = sprintf(__(" View %s and enter icon name ex. user", 'ct_theme'), '<a target="_blank" id="open_venue_icon' . '" href="' . CT_THEME_ASSETS . '/shortcode/awesome/index.html' . '">' . __('available icons', 'ct_theme') . '</a>')?>
  62. <p class="howto"><?php echo __("Link to icon representation of the venue field", 'ct_theme') . $venueIcons?></p>
  63. <p>
  64. <label for="url">Url: </label>
  65. <input id="url" class="regular-text" name="external_url" value="<?php echo $external_url; ?>"/>
  66. </p>
  67. <p class="howto"><?php _e("Link to external site. Leave empty to hide button", 'ct_theme')?></p>
  68. <p>
  69. <label for="external_label">Url label: </label>
  70. <input id="external_label" class="regular-text" name="external_label" value="<?php echo $external_label; ?>"/>
  71. </p>
  72. <p class="howto"><?php _e("Label for the external url", 'ct_theme')?></p>
  73. <p>
  74. <label for="display_method"><?php _e('Show portfolio item as', 'ct_theme')?>: </label>
  75. <select class="ct-toggler" id="display_method" name="display_method">
  76. <option data-group=".display" value="image" <?php echo selected('image', $displayMethod)?>><?php _e("Featured image", 'ct_theme')?></option>
  77. <option data-group=".display" data-toggle=".ct-toggable.gallery" value="gallery" <?php echo selected('gallery', $displayMethod)?>><?php _e("Gallery", 'ct_theme')?></option>
  78. <option data-group=".display" data-toggle=".ct-toggable.video" value="video" <?php echo selected('video', $displayMethod)?>><?php _e("Video", 'ct_theme')?></option>
  79. <?php if ($supportsRevolutionSlider): ?>
  80. <option data-group=".display" data-toggle=".ct-toggable.revolution-slider" value="revolution-slider" <?php echo selected('revolution-slider', $displayMethod)?>><?php _e("Revolution slider gallery", 'ct_theme')?></option>
  81. <?php endif;?>
  82. </select>
  83. </p>
  84. <p class="ct-toggable video display">
  85. <label for="video"><?php _e('Video url', 'ct_theme')?>: </label>
  86. <input id="video" class="regular-text" name="video" value="<?php echo $video; ?>"/>
  87. </p>
  88. <?php if ($supportsRevolutionSlider): ?>
  89. <p class="ct-toggable revolution-slider display">
  90. <label for="revolutionSlider"><?php _e('Revolution slider', 'ct_theme')?>: </label>
  91. <select id="revolutionSlider" name="revolution_slider">
  92. <?php foreach ($slides as $slide): ?>
  93. <option <?php echo selected($slide->alias, $revolution_slider)?> value="<?php echo $slide->alias ?>"><?php echo $slide->title?></option>
  94. <?php endforeach;?>
  95. </select>
  96. </p>
  97. <?php endif; ?>
  98. <?php
  99. }
  100. /**
  101. * portfolio template settings
  102. */
  103. public function portfolioTemplateMeta() {
  104. global $post;
  105. $custom = get_post_custom($post->ID);
  106. $title = isset($custom["show_title"][0]) ? $custom["show_title"][0] : "";
  107. $bread = isset($custom["show_breadcrumbs"][0]) ? $custom["show_breadcrumbs"][0] : "";
  108. $boxed = isset($custom["use_boxed"][0]) ? $custom["use_boxed"][0] : "";
  109. $slider = isset($custom["slider"][0]) ? $custom["slider"][0] : "";
  110. ?>
  111. <p>
  112. <label for="show_title"><?php _e('Show title', 'ct_theme')?>: </label>
  113. <select id="show_title" name="show_title">
  114. <option value="global" <?php echo selected('global', $title)?>><?php _e("use global settings", 'ct_theme')?></option>
  115. <option value="yes" <?php echo selected('yes', $title)?>><?php _e("show title", 'ct_theme')?></option>
  116. <option value="no" <?php echo selected('no', $title)?>><?php _e("hide title", 'ct_theme')?></option>
  117. </select>
  118. </p>
  119. <p class="howto"><?php _e("Show page title?", 'ct_theme')?></p>
  120. <p>
  121. <label for="show_breadcrumbs"><?php _e('Show breadcrumbs', 'ct_theme')?>: </label>
  122. <select id="show_breadcrumbs" name="show_breadcrumbs">
  123. <option value="global" <?php echo selected('global', $bread)?>><?php _e("use global settings", 'ct_theme')?></option>
  124. <option value="yes" <?php echo selected('yes', $bread)?>><?php _e("show breadcrumbs", 'ct_theme')?></option>
  125. <option value="no" <?php echo selected('no', $bread)?>><?php _e("hide breadcrumbs", 'ct_theme')?></option>
  126. </select>
  127. </p>
  128. <p class="howto"><?php _e("Show breadcrumbs?", 'ct_theme')?></p>
  129. <p>
  130. <label for="use_boxed"><?php _e('Use boxed layout', 'ct_theme')?>: </label>
  131. <select id="use_boxed" name="use_boxed">
  132. <option value="global" <?php echo selected('global', $boxed)?>><?php _e("use global settings", 'ct_theme')?></option>
  133. <option value="yes" <?php echo selected('yes', $boxed)?>><?php _e("boxed layout", 'ct_theme')?></option>
  134. <option value="no" <?php echo selected('no', $boxed)?>><?php _e("full layout", 'ct_theme')?></option>
  135. </select>
  136. </p>
  137. <p class="howto"><?php _e("Use boxed or full layout template for this page?", 'ct_theme')?></p>
  138. <p>
  139. <label for="slider"><?php _e('Top slider', 'ct_theme')?>: </label>
  140. <textarea id="slider" class="regular-text" name="slider" cols="100" rows="10"><?php echo $slider; ?></textarea>
  141. </p>
  142. <p class="howto"><?php _e("Top slider code", 'ct_theme')?></p>
  143. <?php
  144. }
  145. public function saveDetails() {
  146. parent::saveDetails();
  147. global $post;
  148. $fields = array('client_icon', 'date', 'date_icon', 'venue', 'venue_icon', 'tools', 'tools_icon', 'external_label', 'show_title', 'show_breadcrumbs', 'use_boxed', 'slider');
  149. foreach ($fields as $field) {
  150. if (isset($_POST[$field])) {
  151. update_post_meta($post->ID, $field, $_POST[$field]);
  152. }
  153. }
  154. }
  155. }
  156. new ctPortfolioType();