SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | ||
| 3 | function flo__autoload($class_name) | |
| 4 | {
| |
| 5 | ||
| 6 | if (substr($class_name, 0, 6) == 'widget') {
| |
| 7 | $class_name = str_replace('widget_', '', $class_name);
| |
| 8 | if (is_file(get_template_directory() . '/lib/php/widget/' . $class_name . '.php')) {
| |
| 9 | include get_template_directory() . '/lib/php/widget/' . $class_name . '.php'; | |
| 10 | ||
| 11 | } | |
| 12 | } | |
| 13 | if (is_file(get_template_directory() . '/lib/php/' . $class_name . '.class.php')) {
| |
| 14 | include_once get_template_directory() . '/lib/php/' . $class_name . '.class.php'; | |
| 15 | if (is_file(get_template_directory() . '/lib/php/' . $class_name . '.register.php')) {
| |
| 16 | include_once get_template_directory() . '/lib/php/' . $class_name . '.register.php'; | |
| 17 | } | |
| 18 | } | |
| 19 | } | |
| 20 | ||
| 21 | spl_autoload_register("flo__autoload");
| |
| 22 | ||
| 23 | ||
| 24 | /*register tags and categories taxonomies for video posts*/ | |
| 25 | $video_categ_permalink = options::get_value('general', 'video_categ_link');
| |
| 26 | if (!$video_categ_permalink) {
| |
| 27 | $video_categ_permalink = 'video-category'; | |
| 28 | } | |
| 29 | ||
| 30 | $video_tags_permalink = options::get_value('general', 'video_tags_link');
| |
| 31 | if (!$video_tags_permalink) {
| |
| 32 | $video_tags_permalink = 'video-tag'; | |
| 33 | } | |
| 34 | ||
| 35 | ||
| 36 | $video_category = array( | |
| 37 | 'hierarchical' => true, | |
| 38 | 'labels' => array( | |
| 39 | 'name' => _x('Video Categories', 'taxonomy general name', 'flotheme'),
| |
| 40 | 'singular_name' => _x('Video Category', 'taxonomy singular name', 'flotheme'),
| |
| 41 | 'search_items' => __('Search Categories', 'flotheme'),
| |
| 42 | 'all_items' => __('All Categories', 'flotheme'),
| |
| 43 | 'parent_item' => __('Parent Category', 'flotheme'),
| |
| 44 | 'parent_item_colon' => __('Parent Category:', 'flotheme'),
| |
| 45 | 'edit_item' => __('Edit Category', 'flotheme'),
| |
| 46 | 'update_item' => __('Update Category', 'flotheme'),
| |
| 47 | 'add_new_item' => __('Add New Category', 'flotheme'),
| |
| 48 | 'new_item_name' => __('New Category Name', 'flotheme'),
| |
| 49 | 'menu_name' => __('Categories', 'flotheme'),
| |
| 50 | ), | |
| 51 | 'show_ui' => true, | |
| 52 | 'query_var' => true, | |
| 53 | 'rewrite' => array('slug' => $video_categ_permalink),
| |
| 54 | ); | |
| 55 | ||
| 56 | $video_tag = array( | |
| 57 | 'hierarchical' => false, | |
| 58 | 'labels' => array( | |
| 59 | 'name' => _x('Video Tags', 'taxonomy general name', 'flotheme'),
| |
| 60 | 'singular_name' => _x('Video Tag', 'taxonomy singular name', 'flotheme'),
| |
| 61 | 'search_items' => __('Search Tags', 'flotheme'),
| |
| 62 | 'popular_items' => __('Popular Tags', 'flotheme'),
| |
| 63 | 'all_items' => __('All Tags', 'flotheme'),
| |
| 64 | 'parent_item' => NULL, | |
| 65 | 'parent_item_colon' => NULL, | |
| 66 | 'edit_item' => __('Edit Tag', 'flotheme'),
| |
| 67 | 'update_item' => __('Update Tag', 'flotheme'),
| |
| 68 | 'add_new_item' => __('Add New Tag', 'flotheme'),
| |
| 69 | 'new_item_name' => __('New Tag Name', 'flotheme'),
| |
| 70 | 'separate_items_with_commas' => __('Separate tags with commas', 'flotheme'),
| |
| 71 | 'add_or_remove_items' => __('Add or remove tags', 'flotheme'),
| |
| 72 | 'choose_from_most_used' => __('Choose from the most used tags', 'flotheme'),
| |
| 73 | 'menu_name' => __('Tags', 'flotheme'),
| |
| 74 | ), | |
| 75 | 'show_ui' => true, | |
| 76 | 'update_count_callback' => '_update_post_term_count', | |
| 77 | 'query_var' => true, | |
| 78 | 'rewrite' => array('slug' => $video_tags_permalink),
| |
| 79 | ); | |
| 80 | ||
| 81 | register_taxonomy('video-category', 'video', $video_category);
| |
| 82 | register_taxonomy('video-tag', 'video', $video_tag);
| |
| 83 | /* EOF register tags and categories taxonomies for video posts */ | |
| 84 | ||
| 85 | ||
| 86 | ||
| 87 | ||
| 88 | /*register tags and categories taxonomies for gallery posts*/ | |
| 89 | $gallery_categ_permalink = options::get_value('general', 'gallery_categ_link');
| |
| 90 | if (!$gallery_categ_permalink) {
| |
| 91 | $gallery_categ_permalink = 'gallery-category'; | |
| 92 | } | |
| 93 | ||
| 94 | $gallery_tags_permalink = options::get_value('general', 'gallery_tags_link');
| |
| 95 | if (!$gallery_tags_permalink) {
| |
| 96 | $gallery_tags_permalink = 'gallery-tag'; | |
| 97 | } | |
| 98 | ||
| 99 | $gallery_category = array( | |
| 100 | 'hierarchical' => true, | |
| 101 | 'labels' => array( | |
| 102 | 'name' => _x('Gallery Categories', 'taxonomy general name', 'flotheme'),
| |
| 103 | 'singular_name' => _x('Gallery Category', 'taxonomy singular name', 'flotheme'),
| |
| 104 | 'search_items' => __('Search Categories', 'flotheme'),
| |
| 105 | 'all_items' => __('All Categories', 'flotheme'),
| |
| 106 | 'parent_item' => __('Parent Category', 'flotheme'),
| |
| 107 | 'parent_item_colon' => __('Parent Category:', 'flotheme'),
| |
| 108 | 'edit_item' => __('Edit Category', 'flotheme'),
| |
| 109 | 'update_item' => __('Update Category', 'flotheme'),
| |
| 110 | 'add_new_item' => __('Add New Category', 'flotheme'),
| |
| 111 | 'new_item_name' => __('New Category Name', 'flotheme'),
| |
| 112 | 'menu_name' => __('Categories', 'flotheme'),
| |
| 113 | ), | |
| 114 | 'show_ui' => true, | |
| 115 | 'query_var' => true, | |
| 116 | 'rewrite' => array('slug' => $gallery_categ_permalink),
| |
| 117 | ); | |
| 118 | ||
| 119 | $gallery_tag = array( | |
| 120 | 'hierarchical' => false, | |
| 121 | 'labels' => array( | |
| 122 | 'name' => _x('Gallery Tags', 'taxonomy general name', 'flotheme'),
| |
| 123 | 'singular_name' => _x('Gallery Tag', 'taxonomy singular name', 'flotheme'),
| |
| 124 | 'search_items' => __('Search Tags', 'flotheme'),
| |
| 125 | 'popular_items' => __('Popular Tags', 'flotheme'),
| |
| 126 | 'all_items' => __('All Tags', 'flotheme'),
| |
| 127 | 'parent_item' => NULL, | |
| 128 | 'parent_item_colon' => NULL, | |
| 129 | 'edit_item' => __('Edit Tag', 'flotheme'),
| |
| 130 | 'update_item' => __('Update Tag', 'flotheme'),
| |
| 131 | 'add_new_item' => __('Add New Tag', 'flotheme'),
| |
| 132 | 'new_item_name' => __('New Tag Name', 'flotheme'),
| |
| 133 | 'separate_items_with_commas' => __('Separate tags with commas', 'flotheme'),
| |
| 134 | 'add_or_remove_items' => __('Add or remove tags', 'flotheme'),
| |
| 135 | 'choose_from_most_used' => __('Choose from the most used tags', 'flotheme'),
| |
| 136 | 'menu_name' => __('Tags', 'flotheme'),
| |
| 137 | ), | |
| 138 | 'show_ui' => true, | |
| 139 | 'update_count_callback' => '_update_post_term_count', | |
| 140 | 'query_var' => true, | |
| 141 | 'rewrite' => array('slug' => $gallery_tags_permalink),
| |
| 142 | ); | |
| 143 | ||
| 144 | register_taxonomy('gallery-category', 'gallery', $gallery_category);
| |
| 145 | register_taxonomy('gallery-tag', 'gallery', $gallery_tag);
| |
| 146 | /* EOF register tags and categories taxonomies for gallery posts */ | |
| 147 | ||
| 148 | /*register categories taxonomies for testimonial posts*/ | |
| 149 | $testimonial_category = array( | |
| 150 | 'hierarchical' => true, | |
| 151 | 'labels' => array( | |
| 152 | 'name' => _x( 'Testimonial Categories', 'taxonomy general name' ,'flotheme' ), | |
| 153 | 'singular_name' => _x( 'Testimonial Category', 'taxonomy singular name','flotheme' ), | |
| 154 | 'search_items' => __( 'Search Categories', 'flotheme' ), | |
| 155 | 'all_items' => __( 'All Categories', 'flotheme' ), | |
| 156 | 'parent_item' => __( 'Parent Category', 'flotheme' ), | |
| 157 | 'parent_item_colon' => __( 'Parent Category:', 'flotheme' ), | |
| 158 | 'edit_item' => __( 'Edit Category', 'flotheme' ), | |
| 159 | 'update_item' => __( 'Update Category', 'flotheme' ), | |
| 160 | 'add_new_item' => __( 'Add New Category', 'flotheme' ), | |
| 161 | 'new_item_name' => __( 'New Category Name', 'flotheme' ), | |
| 162 | 'menu_name' => __( 'Categories', 'flotheme' ), | |
| 163 | ), | |
| 164 | 'show_ui' => true, | |
| 165 | 'query_var' => true, | |
| 166 | 'rewrite' => array( 'slug' => 'testimonial-category' ), | |
| 167 | ); | |
| 168 | register_taxonomy('testimonial-category', 'testimonial', $testimonial_category);
| |
| 169 | /* EOF register categories for testimonial posts */ | |
| 170 | ||
| 171 | /** | |
| 172 | * Load Theme Variable Data | |
| 173 | * @param string $var | |
| 174 | * @return string | |
| 175 | */ | |
| 176 | function theme_data_variable($var) | |
| 177 | {
| |
| 178 | if (!is_file(STYLESHEETPATH . '/style.css')) {
| |
| 179 | return ''; | |
| 180 | } | |
| 181 | ||
| 182 | $theme_data = wp_get_theme(); | |
| 183 | return $theme_data->{$var};
| |
| 184 | ||
| 185 | } | |
| 186 | ||
| 187 | function get_post_categories($post_id, $only_first_cat = false, $taxonomy = 'category', $margin_elem_start = '', $margin_elem_end = '', $delimiter = ', ', $a_class = '', $show_cat_name = true) | |
| 188 | {
| |
| 189 | ||
| 190 | $cat = ''; | |
| 191 | $categories = wp_get_post_terms($post_id, $taxonomy); | |
| 192 | if (!empty($categories)) {
| |
| 193 | ||
| 194 | $ind = 1; | |
| 195 | foreach ($categories as $category) {
| |
| 196 | $categ = get_category($category); | |
| 197 | if ($ind != count($categories) && !$only_first_cat) {
| |
| 198 | $cat_delimiter = $delimiter; | |
| 199 | } else {
| |
| 200 | $cat_delimiter = ''; | |
| 201 | } | |
| 202 | ||
| 203 | if ($show_cat_name) {
| |
| 204 | $name = $categ->name; | |
| 205 | } else {
| |
| 206 | $name = ''; | |
| 207 | } | |
| 208 | ||
| 209 | $cat .= $margin_elem_start . '<a href="' . get_category_link($category) . '" class="' . $a_class . '">' . $name . $cat_delimiter . '</a>' . $margin_elem_end; | |
| 210 | ||
| 211 | if ($only_first_cat) {
| |
| 212 | break; | |
| 213 | } | |
| 214 | ||
| 215 | ||
| 216 | $ind++; | |
| 217 | } | |
| 218 | ||
| 219 | ||
| 220 | //$cat = __('in','flotheme').' '. $cat;
| |
| 221 | } | |
| 222 | ||
| 223 | return $cat . ' '; | |
| 224 | } | |
| 225 | ||
| 226 | function load_google_fonts() | |
| 227 | {
| |
| 228 | $protocol = is_ssl() ? 'https' : 'http'; | |
| 229 | ||
| 230 | ||
| 231 | $result = ''; | |
| 232 | $fonts = array(); | |
| 233 | ||
| 234 | // $default_system_fonts = array( | |
| 235 | // "Cantarell, Tahoma, Verdana, Helvetica, sans-serif", | |
| 236 | // "'Unica One', Arial, Helvetica, sans-serif", | |
| 237 | // "'Montserrat Subrayada', Arial, Helvetica, sans-serif", | |
| 238 | // 'Arial, Helvetica, sans-serif', | |
| 239 | // 'Times, Georgia, serif', | |
| 240 | // 'Verdana, Tahoma, sans-serif', | |
| 241 | // "'Century Gothic', Helvetica, Arial, sans-serif", | |
| 242 | // 'Helvetica, Arial, sans-serif', | |
| 243 | // 'Georgia, Times, serif', | |
| 244 | // "'Lucida Grande', 'Lucida Sans Unicode', Tahoma, Verdana, sans-serif", | |
| 245 | // 'Palatino, Georgia, serif', | |
| 246 | // 'Tahoma, Verdana, Helvetica, sans-serif', | |
| 247 | // 'Garamond, Palatino, Georgia, serif', | |
| 248 | // 'Courier, monospace', | |
| 249 | // "'Trebuchet MS', Tahoma, Helvetica, sans-serif", | |
| 250 | // "'Comic Sans MS', Arial, sans-serif", | |
| 251 | // 'Bookman, Palatino, Georgia, serif' | |
| 252 | // ); | |
| 253 | ||
| 254 | $default_system_fonts = array( | |
| 255 | "Cantarell", | |
| 256 | "Unica One", | |
| 257 | //"Montserrat Subrayada", | |
| 258 | 'Arial', | |
| 259 | 'Times', | |
| 260 | 'Verdana', | |
| 261 | "Century Gothic", | |
| 262 | 'Helvetica', | |
| 263 | 'Georgia', | |
| 264 | "Lucida Grande", | |
| 265 | 'Palatino', | |
| 266 | 'Tahoma', | |
| 267 | 'Garamond', | |
| 268 | 'Courier', | |
| 269 | "Trebuchet MS", | |
| 270 | "Comic Sans MS", | |
| 271 | 'Bookman' | |
| 272 | ); | |
| 273 | ||
| 274 | $typo = options::get_value('typography');
| |
| 275 | ||
| 276 | ||
| 277 | //deb::e($typo); | |
| 278 | $settings_fonts = array( | |
| 279 | //$typo[ 'general_font_font_family' ], | |
| 280 | $typo[ 'menu_links_font_family'], | |
| 281 | //$typo[ 'menu_menu_description_family'], | |
| 282 | $typo[ 'header_mobile_label_font_family'], | |
| 283 | $typo[ 'slideshow_title_font_family'], | |
| 284 | $typo[ 'slideshow_description_font_family'], | |
| 285 | $typo[ 'logo_font_font_family'], | |
| 286 | $typo[ 'h1_font_font_family'], | |
| 287 | $typo[ 'h2_font_font_family'], | |
| 288 | $typo[ 'h3_font_font_family'], | |
| 289 | $typo[ 'h4_font_font_family'], | |
| 290 | $typo[ 'h5_font_font_family'], | |
| 291 | $typo[ 'h6_font_font_family'], | |
| 292 | $typo[ 'content_text_font_family'], | |
| 293 | $typo[ 'pretitle_font_font_family'], | |
| 294 | $typo[ 'subtitle_font_font_family'], | |
| 295 | $typo[ 'share_font_font_family'], | |
| 296 | $typo[ 'meta_font_font_family' ], | |
| 297 | ||
| 298 | $typo[ 'inputs_font_family'], | |
| 299 | ||
| 300 | $typo[ 'pagination_font_font_family'], | |
| 301 | $typo[ 'footer_title_font_family'], | |
| 302 | $typo[ 'footer_description_font_family'], | |
| 303 | $typo[ 'footer_bottom_text_font_family'], | |
| 304 | $typo[ 'mosaic_title_font_font_family'], | |
| 305 | $typo[ 'mosaic_content_font_font_family'], | |
| 306 | ); | |
| 307 | ||
| 308 | if (options::get_value('styling', 'logo_type') == 'text') {
| |
| 309 | $settings_fonts[] = options::get_value('styling', 'logo_font_family');
| |
| 310 | } | |
| 311 | ||
| 312 | foreach ($settings_fonts as $font) {
| |
| 313 | ||
| 314 | if (options::get_value('typography', 'google_fonts_api_key') == '') { // if google api key is not used
| |
| 315 | if (!empty($font)) {
| |
| 316 | if (strpos($font, '&v1') === false) {
| |
| 317 | $font .= '&v1'; | |
| 318 | } | |
| 319 | } | |
| 320 | } | |
| 321 | ||
| 322 | if (!in_array($font, $fonts)) {
| |
| 323 | ||
| 324 | $fonts[] = $font; /*append each font only 1 time*/ | |
| 325 | } | |
| 326 | } | |
| 327 | ||
| 328 | // check if there are any custom fonts | |
| 329 | $custom_fonts = get_option('_customfonts');
| |
| 330 | $custom_fonts_array = array(); | |
| 331 | ||
| 332 | if (is_array($custom_fonts) && sizeof($custom_fonts)) {
| |
| 333 | foreach ($custom_fonts as $key => $custom_font) {
| |
| 334 | if (isset($custom_font['title']) && strlen($custom_font['title']) && isset($custom_font['fonturl']) && cosmo_isValidURL($custom_font['fonturl'])) {
| |
| 335 | //$custom_fonts_array[$custom_font['title']] = $custom_font['fonturl']; | |
| 336 | $custom_fonts_array[$custom_font['title']] = $custom_font; | |
| 337 | ||
| 338 | } | |
| 339 | } | |
| 340 | } | |
| 341 | ||
| 342 | $flo_custom_fonts = ''; | |
| 343 | ||
| 344 | $counter = 1; | |
| 345 | foreach ($fonts as $g_font) {
| |
| 346 | ||
| 347 | if (strlen( trim(trim($g_font),'&v1') )) {
| |
| 348 | ||
| 349 | if (array_key_exists(str_replace('&v1', '', $g_font), $custom_fonts_array)) { // if used font is a custom font we will load it from local source
| |
| 350 | $c_font = $custom_fonts_array[str_replace('&v1', '', $g_font)];
| |
| 351 | //wp_enqueue_style( 'cosmo-gfont-'.$counter, "$c_font" ); | |
| 352 | ||
| 353 | ||
| 354 | $c_fonts_url = flo_get_custom_font_urls($c_font); | |
| 355 | ||
| 356 | ob_start(); | |
| 357 | ob_clean(); | |
| 358 | ||
| 359 | ?> | |
| 360 | @font-face {
| |
| 361 | font-family: '<?php echo str_replace('&v1', '', $g_font) ?>';
| |
| 362 | font-style: normal; | |
| 363 | src: local('<?php echo str_replace('&v1', '', $g_font) ?>'), <?php echo $c_fonts_url; ?>;
| |
| 364 | } | |
| 365 | <?php | |
| 366 | $flo_custom_fonts .= ob_get_clean(); | |
| 367 | ||
| 368 | } else {
| |
| 369 | ||
| 370 | // usually we have this case when the fonts are loaded usin API KEY and we have several versions of the | |
| 371 | // same font and font name is devided by font style by '|' | |
| 372 | if (strstr($g_font, '|') !== false) {
| |
| 373 | $family_exploded = explode('|', $g_font);
| |
| 374 | ||
| 375 | if(strlen(trim($family_exploded[0]))){ // if the current font has a name (the default font has no name)
| |
| 376 | $font_style_url = $protocol . '://fonts.googleapis.com/css?family=' . trim($family_exploded[0]); // font name | |
| 377 | ||
| 378 | if (isset($family_exploded[1]) && trim($family_exploded[1]) != 'regular') {
| |
| 379 | $font_style_url .= ":" . trim($family_exploded[1]); // add the font style if necessary | |
| 380 | } | |
| 381 | ||
| 382 | wp_enqueue_style('flo-gfont-' . $counter, "$font_style_url");
| |
| 383 | } | |
| 384 | ||
| 385 | } else {
| |
| 386 | ||
| 387 | // enque the font only if it is a google font and not a default one | |
| 388 | ||
| 389 | if (!in_array(str_replace('&v1', '', $g_font), $default_system_fonts) && !flo_is_system_font($g_font, $default_system_fonts) ) {
| |
| 390 | $the_font = str_replace(' ', '+', trim($g_font));
| |
| 391 | ||
| 392 | if(strlen(trim($the_font))){ // if the current font has a name (the default font has no name)
| |
| 393 | wp_enqueue_style('flo-gfont-' . $counter, "$protocol://fonts.googleapis.com/css?family=$the_font' rel='stylesheet' type='text/css");
| |
| 394 | } | |
| 395 | ||
| 396 | } | |
| 397 | } | |
| 398 | ||
| 399 | ||
| 400 | } | |
| 401 | ||
| 402 | ||
| 403 | } | |
| 404 | $counter++; | |
| 405 | } | |
| 406 | ||
| 407 | if (strlen($flo_custom_fonts)) {
| |
| 408 | ?> | |
| 409 | <style type="text/css"> <?php echo $flo_custom_fonts; ?> </style> <?php | |
| 410 | } | |
| 411 | ||
| 412 | } | |
| 413 | ||
| 414 | /* | |
| 415 | * Function flo_get_custom_font_urls | |
| 416 | * | |
| 417 | * Creates the source for the uploaded custom fonts | |
| 418 | * | |
| 419 | * @font_struct (array) array containing the font name and up to 4 URLs | |
| 420 | * @return (str) - the source URLs ready to be used in css for font-face | |
| 421 | */ | |
| 422 | function flo_get_custom_font_urls($font_struct){
| |
| 423 | ||
| 424 | ||
| 425 | $src_url = ''; | |
| 426 | if(isset($font_struct['fonturl'])){
| |
| 427 | $src_url = 'url('.$font_struct['fonturl'].' )' . flo_get_font_format($font_struct['fonturl']);
| |
| 428 | } | |
| 429 | ||
| 430 | // check and load the fonts added in the fields 2,3,4 | |
| 431 | for($i = 2; $i<5; $i++){
| |
| 432 | if(isset( $font_struct[$i.'fonturl'] ) && strlen($font_struct[$i.'fonturl']) ){ // if the user uploaded a font in the current field, we will add it
| |
| 433 | $src_url .= ', '. 'url('.$font_struct[$i.'fonturl'].' )' . flo_get_font_format($font_struct[$i.'fonturl']);
| |
| 434 | } | |
| 435 | } | |
| 436 | ||
| 437 | return $src_url; | |
| 438 | } | |
| 439 | ||
| 440 | ||
| 441 | function flo_get_font_format($font_url){
| |
| 442 | // expected input parameter: | |
| 443 | // http://demo.flothemes.com/cozy/files/2014/09/brandon_reg.otf | |
| 444 | ||
| 445 | $font_format_options = array('svg' => 'svg',
| |
| 446 | 'otf' => 'opentype', | |
| 447 | 'woff' => 'woff', | |
| 448 | 'ttf' => 'truetype' | |
| 449 | ); | |
| 450 | ||
| 451 | $font_format = ''; | |
| 452 | if(strstr($font_url, '.')){ // check if the given url has a dot
| |
| 453 | $font_url_array = explode('.', $font_url);
| |
| 454 | $font_extention = $font_url_array[sizeof($font_url_array)-1]; // this should match the font extention. i.e. 'otf' | |
| 455 | $font_format = " format('".$font_format_options[$font_extention]."')";
| |
| 456 | } | |
| 457 | ||
| 458 | return $font_format; | |
| 459 | } | |
| 460 | ||
| 461 | /* | |
| 462 | * Check if a font is a a system font | |
| 463 | * $params: | |
| 464 | * $font - str -> the passed font | |
| 465 | * $default_system_fonts - array with used default fonts | |
| 466 | * return: bool | |
| 467 | */ | |
| 468 | function flo_is_system_font($font, $default_system_fonts){
| |
| 469 | // If it is a system font then it should come in a format like this: | |
| 470 | // Verdana, Tahoma, sans-serif | |
| 471 | // So we want to split the input tring by ',', and | |
| 472 | ||
| 473 | if(strstr($font, ',')){
| |
| 474 | $font_array = explode(',', $font);
| |
| 475 | if(in_array($font_array[0], $default_system_fonts)){
| |
| 476 | return true; | |
| 477 | }else{
| |
| 478 | return false; | |
| 479 | } | |
| 480 | }else{
| |
| 481 | return false; | |
| 482 | } | |
| 483 | ||
| 484 | } | |
| 485 | ||
| 486 | function flo_get_logo() | |
| 487 | {
| |
| 488 | ||
| 489 | global $logo_class; | |
| 490 | $logo_type = options::get_value('styling', 'logo_type');
| |
| 491 | if ($logo_type == 'image') {
| |
| 492 | ||
| 493 | ||
| 494 | $sl_info = flo_get_page_slyder_info(); | |
| 495 | $logo_pos_options = array('top-left','top-center','top-right','middle-left','middle-center','middle-right');
| |
| 496 | $slideshow_logo_img = options::get_value('styling', 'slideshow_logo_url');
| |
| 497 | $main_logo_img = options::get_value('styling', 'logo_url');
| |
| 498 | ||
| 499 | if(!strlen($slideshow_logo_img)){
| |
| 500 | $slideshow_logo_img = $main_logo_img; | |
| 501 | } | |
| 502 | ||
| 503 | //var_dump(strlen(trim($slideshow_logo_img)),is_flo_full_slider_width_page() ); | |
| 504 | if( strlen(trim($slideshow_logo_img)) && is_flo_full_slider_width_page() && isset($sl_info['selected_slider_id']) && is_numeric($sl_info['selected_slider_id']) | |
| 505 | && $sl_info['selected_slider_id'] > 0 && isset($sl_info['logo_position']) && (in_array($sl_info['logo_position'], $logo_pos_options ) || $sl_info['logo_position'] == 'logo-inside-menu' && $sl_info['menu_position'] == 'crowd-header-over' ) ){
| |
| 506 | ||
| 507 | if(strlen($slideshow_logo_img)){
| |
| 508 | $logo_img = $slideshow_logo_img; | |
| 509 | }else{
| |
| 510 | $logo_img = $main_logo_img; | |
| 511 | } | |
| 512 | ||
| 513 | $desktop_size = options::get_value('styling', 'max_logo_width_desktop_slideshow_page');
| |
| 514 | }else{
| |
| 515 | $logo_img = $main_logo_img; | |
| 516 | $desktop_size = options::get_value('styling', 'max_logo_width_desktop');
| |
| 517 | } | |
| 518 | ||
| 519 | if ($logo_img) {
| |
| 520 | $logo_class = ' site-logo '; | |
| 521 | ||
| 522 | $mobile_logo_img = options::get_value('styling', 'logo_url_mobile');
| |
| 523 | ||
| 524 | // $logo_dim = aq_resize( esc_url($logo_img), '9999', '99999', false, false ); | |
| 525 | ||
| 526 | $orig_w = isset($logo_dim[1]) ? $logo_dim[1] : ''; | |
| 527 | $orig_h = isset($logo_dim[2]) ? $logo_dim[2] : ''; | |
| 528 | $mobile_size = options::get_value('styling', 'max_logo_width_mobile')? options::get_value('styling', 'max_logo_width_mobile'): 9999;
| |
| 529 | if(strlen($mobile_logo_img)){
| |
| 530 | // $mobile_logo_img = aq_resize( esc_url($mobile_logo_img), $mobile_size, 9999, false, true); | |
| 531 | $mobile_logo = "<img src='" . $mobile_logo_img . "' alt='".get_bloginfo('name')."' class='crowd-mobile-logo' />";
| |
| 532 | }else{
| |
| 533 | // $m_logo_img = aq_resize( esc_url($logo_img), $mobile_size, 9999, false, true); | |
| 534 | $mobile_logo = "<img src='" . $logo_img . "' alt='".get_bloginfo('name')."' class='crowd-mobile-logo' />";
| |
| 535 | } | |
| 536 | $desktop_size = $desktop_size? $desktop_size: 9999; | |
| 537 | // $logo_img = aq_resize( esc_url($logo_img), $desktop_size, 9999, false, true); | |
| 538 | $logo = "<div class='site-title'> | |
| 539 | <a class='logo' href='".home_url()."' rel='home' > | |
| 540 | <img src='" . $logo_img . "' alt='".get_bloginfo('name')."' class='crowd-descktop-logo' width='".$orig_w."' height='".$orig_h."' />
| |
| 541 | ".$mobile_logo." | |
| 542 | </a> | |
| 543 | </div>"; | |
| 544 | ||
| 545 | } else {
| |
| 546 | $logo_class = ' '; | |
| 547 | $logo = NULL; | |
| 548 | } | |
| 549 | if (!$logo) {
| |
| 550 | $logo .= '<div class="site-title"><a href="'.home_url().'" rel="home">'.get_bloginfo('name').'</a></div>';
| |
| 551 | $logo_class = ' '; | |
| 552 | } | |
| 553 | } else {
| |
| 554 | $logo_class = ' '; | |
| 555 | $logo = '<div class="site-title"><a href="'.home_url().'" rel="home">'.get_bloginfo('name').'</a></div>';
| |
| 556 | } | |
| 557 | ||
| 558 | return $logo; | |
| 559 | } | |
| 560 | ||
| 561 | function get_item_label($item) | |
| 562 | {
| |
| 563 | $item = basename($item); | |
| 564 | $item = str_replace('-', ' ', $item);
| |
| 565 | return $item; | |
| 566 | } | |
| 567 | ||
| 568 | function get__categories($nr = -1) | |
| 569 | {
| |
| 570 | $categories = get_categories(); | |
| 571 | ||
| 572 | $result = array(); | |
| 573 | foreach ($categories as $key => $category) {
| |
| 574 | if ($key == $nr) {
| |
| 575 | break; | |
| 576 | } | |
| 577 | if ($nr > 0) {
| |
| 578 | $result[$category->term_id] = $category->term_id; | |
| 579 | } else {
| |
| 580 | $result[$category->term_id] = $category->cat_name; | |
| 581 | } | |
| 582 | } | |
| 583 | ||
| 584 | return $result; | |
| 585 | } | |
| 586 | ||
| 587 | function get__pages($first_label = 'Select item') | |
| 588 | {
| |
| 589 | $pages = get_pages(); | |
| 590 | $result = array(); | |
| 591 | if (is_array($first_label)) {
| |
| 592 | $result = $first_label; | |
| 593 | } else {
| |
| 594 | if (strlen($first_label)) {
| |
| 595 | $result[] = $first_label; | |
| 596 | } | |
| 597 | } | |
| 598 | foreach ($pages as $page) {
| |
| 599 | $result[$page->ID] = $page->post_title; | |
| 600 | } | |
| 601 | ||
| 602 | return $result; | |
| 603 | } | |
| 604 | ||
| 605 | ||
| 606 | /** | |
| 607 | * adds the language switcher to the menu object | |
| 608 | * | |
| 609 | * @params: | |
| 610 | * $items - string, the menu items in html format | |
| 611 | * $args - array, menu config arguments | |
| 612 | * @return - string, the modified menu with them logo in the middle | |
| 613 | */ | |
| 614 | if (!function_exists('flo_add_lang_switcher_to_nav')) {
| |
| 615 | function flo_add_lang_switcher_to_nav($items, $args){
| |
| 616 | if(is_object($args->walker)){
| |
| 617 | ||
| 618 | ob_start(); | |
| 619 | get_sidebar( 'header-translation' ); | |
| 620 | $lang_switcher = ob_get_contents(); | |
| 621 | ob_end_clean(); | |
| 622 | ||
| 623 | ||
| 624 | $items .= '<li class="menu-lang-switcher">'.$lang_switcher.'</li>'; | |
| 625 | return $items; | |
| 626 | ||
| 627 | }else{
| |
| 628 | return $items; | |
| 629 | } | |
| 630 | } | |
| 631 | ||
| 632 | } | |
| 633 | ||
| 634 | /** | |
| 635 | * adds the logo to the menu object | |
| 636 | * | |
| 637 | * @params: | |
| 638 | * $items - string, the menu items in html format | |
| 639 | * $args - array, menu config arguments | |
| 640 | * @return - string, the modified menu with them logo in the middle | |
| 641 | */ | |
| 642 | if (!function_exists('flo_add_menu_to_nav')) {
| |
| 643 | function flo_add_menu_to_nav($items, $args){
| |
| 644 | ||
| 645 | if(is_object($args->walker)){
| |
| 646 | $number_menu_items = $args->walker->count; | |
| 647 | ||
| 648 | // now we need to find the index of the menu item where the LOGO will be inserted. i.e. if the menu has 6 menu items, then the logo will be inserted after the 3rd elem. | |
| 649 | $before_logo_index = round( $number_menu_items/2); | |
| 650 | ||
| 651 | ||
| 652 | if(!class_exists('simple_html_dom_node')){ // make sure we will not have conflicts with other plugins that are using simple_html_dom class
| |
| 653 | require('simple_html_dom.php');
| |
| 654 | } | |
| 655 | ||
| 656 | // now we will parse the menu items dom using simple_html_dom library | |
| 657 | $html = new simple_html_dom(); | |
| 658 | $html->load('<ul class="temp-wrapper">'.$items.'</ul>');
| |
| 659 | ||
| 660 | $temp_wrapper = $html->find('.description', 0);
| |
| 661 | if(($temp_wrapper)) {
| |
| 662 | $menu_items = $html->find('.temp-wrapper', 0)->children(); // get just the top level menu items
| |
| 663 | ||
| 664 | $new_menu = ''; // init and empty menu that will be built from the old menu + the logo | |
| 665 | foreach ($menu_items as $key => $value) {
| |
| 666 | $original_class = $value->class; | |
| 667 | ||
| 668 | ||
| 669 | // update the class | |
| 670 | if( $key < $before_logo_index){
| |
| 671 | $value->class = $original_class . ' left-logo-menu '; | |
| 672 | }else{
| |
| 673 | $value->class = $original_class . ' right-logo-menu '; | |
| 674 | } | |
| 675 | ||
| 676 | $new_menu .= $value->outertext; | |
| 677 | ||
| 678 | // if we are in the middle of the menu, add the logo | |
| 679 | if($before_logo_index == $key+1){
| |
| 680 | ||
| 681 | $the_logo = flo_get_logo(); | |
| 682 | ||
| 683 | $new_menu .= '<li class="menu-item logo-inside site-logo">'.$the_logo.'</li>'; | |
| 684 | } | |
| 685 | ||
| 686 | } | |
| 687 | } | |
| 688 | ||
| 689 | return $new_menu; | |
| 690 | ||
| 691 | }else{
| |
| 692 | return $items; | |
| 693 | } | |
| 694 | ||
| 695 | } | |
| 696 | } | |
| 697 | ||
| 698 | function get__posts($args = array(), $first_label = 'Select item') | |
| 699 | {
| |
| 700 | $posts = get_posts($args); | |
| 701 | $result = array(); | |
| 702 | ||
| 703 | if (is_array($first_label)) {
| |
| 704 | $result = $first_label; | |
| 705 | } else {
| |
| 706 | if (strlen($first_label)) {
| |
| 707 | $result[] = $first_label; | |
| 708 | } | |
| 709 | } | |
| 710 | if (is_array($posts) && !empty($posts)) {
| |
| 711 | foreach ($posts as $post) {
| |
| 712 | $result[$post->ID] = $post->post_title; | |
| 713 | } | |
| 714 | } | |
| 715 | ||
| 716 | return $result; | |
| 717 | } | |
| 718 | ||
| 719 | function menu($id, $args = array()) | |
| 720 | {
| |
| 721 | ||
| 722 | $menu = new menu($args); | |
| 723 | ||
| 724 | $vargs = array( | |
| 725 | 'menu' => '', | |
| 726 | 'container' => '', | |
| 727 | 'container_class' => '', | |
| 728 | 'container_id' => '', | |
| 729 | 'menu_class' => isset($args['class']) ? $args['class'] : '', | |
| 730 | 'menu_id' => '', | |
| 731 | 'echo' => false, | |
| 732 | 'fallback_cb' => 'flo_page_menu', | |
| 733 | 'before' => '', | |
| 734 | 'after' => '', | |
| 735 | 'link_before' => '', | |
| 736 | 'link_after' => '', | |
| 737 | 'depth' => 0, | |
| 738 | 'walker' => $menu, | |
| 739 | 'theme_location' => $id, | |
| 740 | 'nr_items_per_column' => isset($args['nr_items_per_column']) ? $args['nr_items_per_column'] : 9999, /// if you don't want to have several columns in menu, set 9999 | |
| 741 | ); | |
| 742 | ||
| 743 | $result = wp_nav_menu($vargs); | |
| 744 | ||
| 745 | ||
| 746 | if ($menu->need_more && $id != 'megusta') {
| |
| 747 | $result .= "</li></ul>" . $menu->aftersubm; | |
| 748 | } | |
| 749 | ||
| 750 | return $result; | |
| 751 | } | |
| 752 | ||
| 753 | /** | |
| 754 | * Override the defaul WP_page_menu function to have the output we need | |
| 755 | * Display or retrieve list of pages with optional home link. | |
| 756 | * | |
| 757 | * The arguments are listed below and part of the arguments are for {@link
| |
| 758 | * wp_list_pages()} function. Check that function for more info on those | |
| 759 | * arguments. | |
| 760 | * | |
| 761 | * @since 4.0.0 | |
| 762 | * | |
| 763 | * @param array|string $args {
| |
| 764 | * Optional. Arguments to generate a page menu. {@see wp_list_pages()}
| |
| 765 | * for additional arguments. | |
| 766 | * | |
| 767 | * @type string $sort_column How to short the list of pages. Accepts post column names. | |
| 768 | * Default 'menu_order, post_title'. | |
| 769 | * @type string $menu_class Class to use for the div ID containing the page list. Default 'menu'. | |
| 770 | * @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return). | |
| 771 | * Default true. | |
| 772 | * @type string $link_before The HTML or text to prepend to $show_home text. Default empty. | |
| 773 | * @type string $link_after The HTML or text to append to $show_home text. Default empty. | |
| 774 | * @type int|string $show_home Whether to display the link to the home page. Can just enter the text | |
| 775 | * you'd like shown for the home link. 1|true defaults to 'Home'. | |
| 776 | * } | |
| 777 | * @return string html menu | |
| 778 | */ | |
| 779 | function flo_page_menu( $args = array() ) {
| |
| 780 | $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
| |
| 781 | $args = wp_parse_args( $args, $defaults ); | |
| 782 | ||
| 783 | $menu = ''; | |
| 784 | ||
| 785 | $list_args = $args; | |
| 786 | ||
| 787 | // Show Home in the menu | |
| 788 | if ( ! empty($args['show_home']) ) {
| |
| 789 | if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) | |
| 790 | $text = __('Home','flotheme');
| |
| 791 | else | |
| 792 | $text = $args['show_home']; | |
| 793 | $class = ''; | |
| 794 | if ( is_front_page() && !is_paged() ) | |
| 795 | $class = 'class="current_page_item"'; | |
| 796 | $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; | |
| 797 | // If the front page is a page, add it to the exclude list | |
| 798 | if (get_option('show_on_front') == 'page') {
| |
| 799 | if ( !empty( $list_args['exclude'] ) ) {
| |
| 800 | $list_args['exclude'] .= ','; | |
| 801 | } else {
| |
| 802 | $list_args['exclude'] = ''; | |
| 803 | } | |
| 804 | $list_args['exclude'] .= get_option('page_on_front');
| |
| 805 | } | |
| 806 | } | |
| 807 | ||
| 808 | $list_args['echo'] = false; | |
| 809 | $list_args['title_li'] = ''; | |
| 810 | $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) ); | |
| 811 | ||
| 812 | if ( $menu ) | |
| 813 | $menu = '<ul class="' . esc_attr($args['menu_class']) . '">' . $menu . '</ul>'; | |
| 814 | ||
| 815 | //$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; | |
| 816 | ||
| 817 | ||
| 818 | if ( $args['echo'] ) | |
| 819 | echo $menu; | |
| 820 | else | |
| 821 | return $menu; | |
| 822 | } | |
| 823 | ||
| 824 | if (!function_exists('clear_meta')) {
| |
| 825 | function clear_meta($post_id) | |
| 826 | {
| |
| 827 | ||
| 828 | $resources = array('conference' => array('sponsor', 'presentation', 'exhibitor'), 'presentation' => array('speaker'));
| |
| 829 | foreach ($resources as $res => $boxes) {
| |
| 830 | $posts = get_posts(array('post_type' => $res));
| |
| 831 | foreach ($posts as $post) {
| |
| 832 | foreach ($boxes as $box) {
| |
| 833 | $box_meta = meta::get_meta($post->ID, $box); | |
| 834 | foreach ($box_meta as $index => $meta) {
| |
| 835 | if ($meta['idrecord'] == $post_id) {
| |
| 836 | meta::delete($res, $box, $post->ID, '', $index); | |
| 837 | } | |
| 838 | } | |
| 839 | } | |
| 840 | } | |
| 841 | } | |
| 842 | } | |
| 843 | } | |
| 844 | ||
| 845 | if (!function_exists('cosmo_breadcrumbs')) {
| |
| 846 | function cosmo_breadcrumbs() | |
| 847 | {
| |
| 848 | ||
| 849 | $delimiter = ''; | |
| 850 | $home = __('Home', 'flotheme'); // text for the 'Home' link
| |
| 851 | ||
| 852 | $start_container = '<ul>'; | |
| 853 | $end_container = '</ul>'; | |
| 854 | $before = '<li>'; // tag before the current crumb | |
| 855 | $after = '</li>'; // tag after the current crumb | |
| 856 | ||
| 857 | if (!is_front_page() || is_paged()) {
| |
| 858 | ||
| 859 | /*echo '<div id="crumbs">';*/ | |
| 860 | ||
| 861 | global $post; | |
| 862 | $homeLink = home_url(); | |
| 863 | echo $start_container; | |
| 864 | echo '<li><a href="' . $homeLink . '">' . $home . '</a> </li>' . $delimiter . ' '; | |
| 865 | ||
| 866 | if (is_category()) {
| |
| 867 | global $wp_query; | |
| 868 | $cat_obj = $wp_query->get_queried_object(); | |
| 869 | $thisCat = $cat_obj->term_id; | |
| 870 | $thisCat = get_category($thisCat); | |
| 871 | $parentCat = get_category($thisCat->parent); | |
| 872 | if ($thisCat->parent != 0) | |
| 873 | echo($before . get_category_parents($parentCat, true, ' ' . '</li><li>' . ' ') . $after); | |
| 874 | echo $before . __('Archive by category', 'flotheme') . ' "' . single_cat_title('', false) . '"' . $after;
| |
| 875 | ||
| 876 | } elseif (is_day()) {
| |
| 877 | echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $after . $delimiter . ' ';
| |
| 878 | echo $before . '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $after . $delimiter . ' ';
| |
| 879 | echo $before . get_the_time('d') . $after;
| |
| 880 | ||
| 881 | } elseif (is_month()) {
| |
| 882 | echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $after . $delimiter . ' ';
| |
| 883 | echo $before . get_the_time('F') . $after;
| |
| 884 | ||
| 885 | } elseif (is_year()) {
| |
| 886 | echo $before . get_the_time('Y') . $after;
| |
| 887 | ||
| 888 | } elseif (is_single() && !is_attachment()) {
| |
| 889 | if (get_post_type() != 'post') {
| |
| 890 | ||
| 891 | $post_type = get_post_type_object(get_post_type()); | |
| 892 | $slug = $post_type->rewrite; | |
| 893 | echo $before . '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $after . $delimiter . ' '; | |
| 894 | echo $before . get_the_title() . $after; | |
| 895 | } else {
| |
| 896 | $cat = get_the_category(); | |
| 897 | $cat = $cat[0]; | |
| 898 | //echo $before . get_category_parents($cat, TRUE, ' ' . '</li><li>' . ' ') . $after; | |
| 899 | echo $before . get_category_parents($cat, true, ' ') . $after; | |
| 900 | echo $before . get_the_title() . $after; | |
| 901 | } | |
| 902 | ||
| 903 | } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
| |
| 904 | $post_type = get_post_type_object(get_post_type()); | |
| 905 | if ($post_type) {
| |
| 906 | echo $before . $post_type->labels->singular_name . $after; | |
| 907 | } | |
| 908 | ||
| 909 | } elseif (is_attachment()) {
| |
| 910 | $parent = get_post($post->post_parent); | |
| 911 | /*$cat = get_the_category($parent->ID); $cat = $cat[0];*/ | |
| 912 | /*echo $before . get_category_parents($cat, TRUE, ' ' . $delimiter . ' ') . $after;*/ | |
| 913 | echo $before . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $after . $delimiter . ' '; | |
| 914 | echo $before . get_the_title() . $after; | |
| 915 | ||
| 916 | } elseif (is_page() && !$post->post_parent) {
| |
| 917 | echo $before . get_the_title() . $after; | |
| 918 | ||
| 919 | } elseif (is_page() && $post->post_parent) {
| |
| 920 | $parent_id = $post->post_parent; | |
| 921 | $breadcrumbs = array(); | |
| 922 | while ($parent_id) {
| |
| 923 | $page = get_page($parent_id); | |
| 924 | $breadcrumbs[] = $before . '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>' . $after; | |
| 925 | $parent_id = $page->post_parent; | |
| 926 | } | |
| 927 | $breadcrumbs = array_reverse($breadcrumbs); | |
| 928 | foreach ($breadcrumbs as $crumb) | |
| 929 | echo $crumb . ' ' . $delimiter . ' '; | |
| 930 | echo $before . get_the_title() . $after; | |
| 931 | ||
| 932 | } elseif (is_search()) {
| |
| 933 | echo $before . __('Search results for', 'flotheme') . ' "' . get_search_query() . '"' . $after;
| |
| 934 | ||
| 935 | } elseif (is_tag()) {
| |
| 936 | echo $before . __('Posts tagged', 'flotheme') . ' "' . single_tag_title('', false) . '"' . $after;
| |
| 937 | ||
| 938 | } elseif (is_author()) {
| |
| 939 | global $author; | |
| 940 | $userdata = get_userdata($author); | |
| 941 | echo $before . __('Articles posted by ', 'flotheme') . $userdata->display_name . $after;
| |
| 942 | ||
| 943 | } elseif (is_404()) {
| |
| 944 | echo $before . __('Error 404', 'flotheme') . $after;
| |
| 945 | } | |
| 946 | ||
| 947 | if (get_query_var('paged')) {
| |
| 948 | if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) | |
| 949 | echo ' (';
| |
| 950 | echo __('Page', 'flotheme') . ' ' . get_query_var('paged');
| |
| 951 | if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) | |
| 952 | echo ')'; | |
| 953 | } | |
| 954 | ||
| 955 | if (is_home()) {
| |
| 956 | echo $before . __('Blog', 'flotheme') . $after;
| |
| 957 | } | |
| 958 | echo $end_container; | |
| 959 | /*echo '</div>';*/ | |
| 960 | ||
| 961 | } | |
| 962 | } /* end cosmo_breadcrumbs()*/ | |
| 963 | } | |
| 964 | ||
| 965 | ||
| 966 | if (!function_exists('cosmo_get_custom_css')) {
| |
| 967 | function cosmo_get_custom_css() | |
| 968 | {
| |
| 969 | ||
| 970 | if (strlen(options::get_value('colors', 'thumb_bg_opacity'))) {
| |
| 971 | $thumb_bg_opacity = options::get_value('colors', 'thumb_bg_opacity');
| |
| 972 | } else {
| |
| 973 | $thumb_bg_opacity = ''; | |
| 974 | } | |
| 975 | ||
| 976 | $logo_position = options::get_value('header_settings', 'logo_position');
| |
| 977 | ||
| 978 | ||
| 979 | $post_images_distance = options::get_value('blog_post', 'images_distance'); // The horizontal distance between images inserted in hte post content
| |
| 980 | ||
| 981 | $single_layout_padding_top = options::get_value('blog_post', 'single_title_padding_top');
| |
| 982 | $single_layout_padding_bottom = options::get_value('blog_post', 'single_title_padding_bottom');
| |
| 983 | ||
| 984 | ||
| 985 | $background_img = ''; | |
| 986 | $header_background_img = ''; | |
| 987 | $background_color = ''; | |
| 988 | $position = ''; | |
| 989 | $repeat = ''; | |
| 990 | $bgatt = ''; | |
| 991 | $thumb_hover_background_img = ''; | |
| 992 | ||
| 993 | ||
| 994 | // $slide_img_width = options::get_value('imagesizes', 'list_view_width') . 'px';
| |
| 995 | ||
| 996 | $home_grid_horizontal_height = options::get_value('imagesizes', 'height_horizontal_home') . 'px';
| |
| 997 | $home_grid_vertical_height = options::get_value('imagesizes', 'height_vertical_home') . 'px';
| |
| 998 | ||
| 999 | /* header 1 submenu font size */ | |
| 1000 | $navigation_font_size = options::get_value('typography', 'navigation_font_font_size');
| |
| 1001 | $submenu_nav_font_size = $navigation_font_size - 2; | |
| 1002 | $header_uppercase_menu = options::get_value('header_settings', 'header_uppercase_menu');
| |
| 1003 | ||
| 1004 | ?> | |
| 1005 | ||
| 1006 | <!--Custom CSS--> | |
| 1007 | <?php if (strlen(options::get_value('custom_css', 'css')) > 0) { ?>
| |
| 1008 | <style type="text/css"> | |
| 1009 | <?php echo options::get_value( 'custom_css' , 'css' ); ?> | |
| 1010 | </style> | |
| 1011 | ||
| 1012 | <?php } ?> | |
| 1013 | <style type="text/css"> | |
| 1014 | ||
| 1015 | <?php | |
| 1016 | $grid_hover_color = options::get_value( 'content_settings' , 'grid_hover_color' ); | |
| 1017 | ||
| 1018 | if(isset($grid_hover_color) && $grid_hover_color != ''){?>
| |
| 1019 | @media only screen and (min-width: 64.063em){
| |
| 1020 | .title-over .post-preview-hidden {
| |
| 1021 | background-color: <?php echo $grid_hover_color;?>; | |
| 1022 | } | |
| 1023 | } | |
| 1024 | <?php }?> | |
| 1025 | <?php | |
| 1026 | $grid_padding = options::get_value( 'content_settings' , 'grid_padding' ); | |
| 1027 | ||
| 1028 | if(isset($grid_hover_color) && $grid_hover_color != ''){?>
| |
| 1029 | @media only screen and (min-width: 64.063em){
| |
| 1030 | .title-over .post-preview-hidden {
| |
| 1031 | left: <?php echo $grid_padding;?>px!important; | |
| 1032 | right: <?php echo $grid_padding;?>px!important; | |
| 1033 | top: <?php echo $grid_padding;?>px!important; | |
| 1034 | bottom: <?php echo $grid_padding;?>px!important; | |
| 1035 | } | |
| 1036 | } | |
| 1037 | <?php }?> | |
| 1038 | ||
| 1039 | ||
| 1040 | <?php if(isset($header_uppercase_menu) && $header_uppercase_menu == 'yes'){;?>
| |
| 1041 | .nav-menu li a{
| |
| 1042 | text-transform: uppercase; | |
| 1043 | } | |
| 1044 | <?php } ?> | |
| 1045 | <?php if(is_numeric($single_layout_padding_top)){?>
| |
| 1046 | .single-layout-width .post-article-title-left, .single-layout-width{
| |
| 1047 | padding-top: <?php echo $single_layout_padding_top;?>px; | |
| 1048 | } | |
| 1049 | <?php } | |
| 1050 | if(is_numeric($single_layout_padding_bottom)){?>
| |
| 1051 | .single-layout-width .post-header{
| |
| 1052 | margin-bottom: <?php echo $single_layout_padding_bottom;?>px; | |
| 1053 | } | |
| 1054 | <?php | |
| 1055 | } | |
| 1056 | ||
| 1057 | $gallery_height = options::get_value('imagesizes','single_gallery_desktop_height');
| |
| 1058 | if($gallery_height){?>
| |
| 1059 | #gallery-slider .royalSlider, #full-width-slider .bx-wrapper{
| |
| 1060 | max-height: <?php echo $gallery_height?>px; | |
| 1061 | } | |
| 1062 | ||
| 1063 | .gallery-slider .flo-slick-slider{
| |
| 1064 | height: <?php echo $gallery_height; ?>px; | |
| 1065 | } | |
| 1066 | ||
| 1067 | <?php } ?> | |
| 1068 | ||
| 1069 | ||
| 1070 | <?php | |
| 1071 | $slick_sl_images_gutter = options::get_value( 'sliders' , 'gallery_visible_nearby_gutter' ); | |
| 1072 | if(is_numeric($slick_sl_images_gutter)){
| |
| 1073 | ?> | |
| 1074 | .flo-slick-slider .slick-slide{
| |
| 1075 | padding: 0px <?php echo $slick_sl_images_gutter; ?>px; | |
| 1076 | } | |
| 1077 | <?php | |
| 1078 | } | |
| 1079 | ||
| 1080 | $slick_main_slideshow_images_gutter = options::get_value( 'sliders' , 'visible_nearby_gutter' ); | |
| 1081 | if(is_numeric($slick_sl_images_gutter)){
| |
| 1082 | ?> | |
| 1083 | .main-slideshow .flo-slick-slider .slick-slide{
| |
| 1084 | padding: 0px <?php echo $slick_main_slideshow_images_gutter/2; ?>px; | |
| 1085 | } | |
| 1086 | <?php | |
| 1087 | } | |
| 1088 | ||
| 1089 | ||
| 1090 | $gallery_mobile_height = options::get_value('imagesizes','single_gallery_mobile_height');
| |
| 1091 | ||
| 1092 | if( is_numeric($gallery_mobile_height) ){ ?>
| |
| 1093 | @media only screen and (max-width: 640px) {
| |
| 1094 | ||
| 1095 | ||
| 1096 | #gallery-slider .royalSlider, #full-width-slider .bx-wrapper {
| |
| 1097 | max-height: <?php echo $gallery_mobile_height ?>px; | |
| 1098 | } | |
| 1099 | ||
| 1100 | .full-width-slider .bx-viewport {
| |
| 1101 | height: <?php echo $gallery_mobile_height?>px !important; | |
| 1102 | } | |
| 1103 | ||
| 1104 | .gallery-slider .flo-slick-slider {
| |
| 1105 | height: <?php echo $gallery_mobile_height; ?>px; | |
| 1106 | } | |
| 1107 | ||
| 1108 | } | |
| 1109 | ||
| 1110 | <?php } | |
| 1111 | //typography styles | |
| 1112 | /*the array keys are the same as the typography options name, and the value are elemets to which the fonts must be applied */ | |
| 1113 | $typography_settings = array( | |
| 1114 | 'menu_links' => '.primary-navigation .nav-menu a, .menu-one-column.logo-left .primary-navigation li a, .menu-one-column.logo-right .primary-navigation li a', | |
| 1115 | 'menu_description' => '.nav-menu li a > .menu-description', | |
| 1116 | 'header_mobile_label' => '.menu-toggle i:before, .menu-toggle span', | |
| 1117 | 'slideshow_title' => '.slide-content .post-title .slide-title', | |
| 1118 | 'slideshow_description' => '.slide-content .post-title .post-title-after', | |
| 1119 | 'logo_font' => '.site-logo div.site-title a, .site-title, .nav-menu .site-title', | |
| 1120 | 'h1_font' => 'h1, h1.post-title, .single-gallery .post-title', | |
| 1121 | 'h2_font' => 'h2' , | |
| 1122 | 'h3_font' => 'h3, .grid-view h3', | |
| 1123 | 'h4_font' => 'h4', | |
| 1124 | 'h5_font' => 'h5', | |
| 1125 | 'h6_font' => 'h6', | |
| 1126 | 'content_text' => 'body, p, span, #content-sidebar ul li a, ul', | |
| 1127 | 'pretitle_font' => '.post-title-before', | |
| 1128 | 'subtitle_font' => '.post-title .post-title-after, .page-template-template-contact-form .contact-form p, .ninja-forms-all-fields-wrap .text-wrap label, .ninja-forms-all-fields-wrap .textarea-wrap label, .ninja-forms-form-wrap label', | |
| 1129 | ||
| 1130 | 'share_font' => '.post-note, .post-comment, .post-tag-entry, .post-tag span, .post-tag a, .share-link, .comment-item, .social-text', | |
| 1131 | 'meta_font' => '.post-date a .post-date, .post-category a, .post-date time, .post-category .category-item', | |
| 1132 | 'pagination_font' => '.pagination span, .pagination a', | |
| 1133 | 'inputs' => 'input[type="text"], input[type="password"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="month"],input[type="week"], input[type="email"], input[type="number"], input[type="search"], input[type="tel"], input[type="time"], input[type="url"], input[type="button"],input[type="submit"], textarea', | |
| 1134 | 'footer_title' => '.widget-title', | |
| 1135 | 'footer_description' => '.button-title-link, .button-title-link span', | |
| 1136 | 'footer_bottom_text' => '.footer-bottom, .footer-bottom a, .footer-bottom span, .footer-bottom p, .footer-bottom div, .footer-bottom span', | |
| 1137 | 'mosaic_content_font' => '.mosaic-description', | |
| 1138 | 'mosaic_title_font' => '.mosaic-title', | |
| 1139 | ||
| 1140 | ); | |
| 1141 | ||
| 1142 | // use 'flo_custom_typography_settings' filter to overwrite the default typography settings elements | |
| 1143 | // it can be used to add more elemnts to be affected by a gived option | |
| 1144 | $typography_settings = apply_filters('flo_custom_typography_settings', $typography_settings);
| |
| 1145 | ||
| 1146 | echo flo_set_typography( $typography_settings ); | |
| 1147 | ?> | |
| 1148 | <?php | |
| 1149 | ||
| 1150 | $full_sidebar_below_header_margin_top = (int)options::get_value( 'blog_post' , 'full_sidebar_below_header_margin_top' ); | |
| 1151 | $full_sidebar_below_header_margin_bottom = (int)options::get_value( 'blog_post' , 'full_sidebar_below_header_margin_bottom' ); | |
| 1152 | if(is_numeric($full_sidebar_below_header_margin_top)){
| |
| 1153 | ?>.below-header-full-width{ margin-top: <?php echo $full_sidebar_below_header_margin_top; ?>px; }<?php
| |
| 1154 | } | |
| 1155 | ||
| 1156 | if(is_numeric($full_sidebar_below_header_margin_bottom)){
| |
| 1157 | ?>.below-header-full-width{ margin-bottom: <?php echo $full_sidebar_below_header_margin_bottom; ?>px; }<?php
| |
| 1158 | } | |
| 1159 | ||
| 1160 | ||
| 1161 | $max_desktop_logo_width = options::get_value( 'styling' , 'max_logo_width_desktop' ); | |
| 1162 | $max_desktop_logo_width_slideshow_page = options::get_value( 'styling' , 'max_logo_width_desktop_slideshow_page' ); | |
| 1163 | $max_mobile_logo_width = options::get_value( 'styling' , 'max_logo_width_mobile' ); | |
| 1164 | ||
| 1165 | $site_width = options::get_value( 'layout' , 'site_width' ); | |
| 1166 | ||
| 1167 | if(!is_numeric($site_width)){
| |
| 1168 | $site_width = 1130; | |
| 1169 | } | |
| 1170 | ?> | |
| 1171 | ||
| 1172 | .row{ max-width: <?php echo $site_width; ?>px; } /*max site content width*/
| |
| 1173 | ||
| 1174 | <?php | |
| 1175 | if(is_numeric($max_desktop_logo_width)){
| |
| 1176 | ?> | |
| 1177 | .site-logo .logo img | |
| 1178 | {
| |
| 1179 | max-width: <?php echo $max_desktop_logo_width ?>px; | |
| 1180 | } | |
| 1181 | ||
| 1182 | <?php | |
| 1183 | } | |
| 1184 | ||
| 1185 | if(is_numeric($max_desktop_logo_width_slideshow_page)){
| |
| 1186 | ?> | |
| 1187 | .crowd-site-identity .site-logo .logo img | |
| 1188 | {
| |
| 1189 | max-width: <?php echo $max_desktop_logo_width_slideshow_page ?>px; | |
| 1190 | } | |
| 1191 | ||
| 1192 | <?php | |
| 1193 | } | |
| 1194 | ||
| 1195 | ||
| 1196 | if(is_numeric($max_mobile_logo_width)){
| |
| 1197 | ?> | |
| 1198 | @media only screen and (max-width: 600px) | |
| 1199 | {
| |
| 1200 | .site-logo .logo img, .crowd-layout .site-header .logo img | |
| 1201 | {
| |
| 1202 | width: <?php echo $max_mobile_logo_width ?>px; | |
| 1203 | } | |
| 1204 | } | |
| 1205 | ||
| 1206 | <?php | |
| 1207 | } | |
| 1208 | ?> | |
| 1209 | ||
| 1210 | <?php | |
| 1211 | if(is_numeric($post_images_distance)){
| |
| 1212 | ?> | |
| 1213 | .single div.post-content a img, .single div.post-content img, body img.alignleft, body img.alignright, body img.aligncenter, body img.alignnone, | |
| 1214 | .gallery-shortcode.flo-1-columns | |
| 1215 | {
| |
| 1216 | margin-bottom: <?php echo $post_images_distance; ?>px; | |
| 1217 | } | |
| 1218 | ||
| 1219 | <?php | |
| 1220 | } | |
| 1221 | ||
| 1222 | $site_width = options::get_value( 'layout' , 'site_width' ); | |
| 1223 | if(!is_numeric($site_width)){
| |
| 1224 | $site_width = 1130; | |
| 1225 | } | |
| 1226 | ||
| 1227 | ||
| 1228 | // set the distance between Header 1 menu items such that the menu | |
| 1229 | // will use the whole content width | |
| 1230 | $header_1_menu_spacing = get_option('header_1_menu_spacing', '0px');
| |
| 1231 | ||
| 1232 | if('0px' != $header_1_menu_spacing && $header_1_menu_spacing > 0){
| |
| 1233 | ||
| 1234 | ?> | |
| 1235 | @media only screen and (min-width: <?php echo $site_width+100; ?>px){
| |
| 1236 | body:not(.crowd-layout).header_style1 .nav-menu>li:not(:last-child){
| |
| 1237 | margin-right: <?php echo $header_1_menu_spacing; ?> | |
| 1238 | } | |
| 1239 | ||
| 1240 | body.crowd-layout.crowd-simple-menu .site-header:not(.left-logo) .nav-menu>li:not(:last-child), | |
| 1241 | body.crowd-layout.crowd-simple-menu .site-header:not(.right-logo) .nav-menu>li:not(:last-child), | |
| 1242 | body.crowd-layout.crowd-simple-menu .site-header:not(.logo-inside-menu) .nav-menu>li:not(:last-child) | |
| 1243 | {
| |
| 1244 | margin-right: <?php echo $header_1_menu_spacing; ?> | |
| 1245 | } | |
| 1246 | ||
| 1247 | body.crowd-layout.crowd-simple-menu .site-header.logo-inside-menu .nav-menu>li:last-child, | |
| 1248 | body.crowd-layout.crowd-simple-menu .site-header.logo-inside-menu .nav-menu>li.right-logo-menu, | |
| 1249 | body.crowd-layout.crowd-simple-menu .site-header.logo-inside-menu .nav-menu>li.site-logo, | |
| 1250 | body.crowd-layout.crowd-simple-menu .site-header .nav-menu>li:last-child{
| |
| 1251 | margin-right: 0px !important; | |
| 1252 | } | |
| 1253 | /*body.crowd-layout.crowd-simple-menu .site-header.logo-inside-menu .nav-menu>li:not(:right-logo-menu)*/ | |
| 1254 | } | |
| 1255 | <?php | |
| 1256 | } | |
| 1257 | ||
| 1258 | ?> | |
| 1259 | ||
| 1260 | @media only screen and (min-width: 641px) and (max-width: <?php echo $site_width+99; ?>px){
| |
| 1261 | .header_style4 .site-navigation .nav-menu>li{
| |
| 1262 | margin-right: 20px !important; | |
| 1263 | margin-left: 0px !important; | |
| 1264 | } | |
| 1265 | } | |
| 1266 | ||
| 1267 | /* fix for the menu items distance if the screen width is smaller that the site content width */ | |
| 1268 | @media only screen and (min-width: 641px) and (max-width: <?php echo $site_width+100; ?>px){
| |
| 1269 | .header_style1 .nav-menu>li:not(:last-child){
| |
| 1270 | margin-right: 15px !important; | |
| 1271 | } | |
| 1272 | } | |
| 1273 | <?php | |
| 1274 | ||
| 1275 | // set the distance between Header 4 menu items such that the menu | |
| 1276 | // will use the whole content width | |
| 1277 | $header_4_menu_left_spacing = get_option('header_4_menu_left_spacing', '0px');
| |
| 1278 | $header_4_menu_right_spacing = get_option('header_4_menu_right_spacing', '0px');
| |
| 1279 | ||
| 1280 | ||
| 1281 | ?> | |
| 1282 | ||
| 1283 | @media only screen and (min-width: <?php echo $site_width+100; ?>px){
| |
| 1284 | .primary-navigation > ul > li.site-logo, .primary-navigation > ul > li.right-logo-menu{
| |
| 1285 | margin-right: 0px; | |
| 1286 | } | |
| 1287 | ||
| 1288 | .header_style4 .site-navigation .nav-menu>li.right-logo-menu{
| |
| 1289 | margin-right: 0px; | |
| 1290 | } | |
| 1291 | .header_style4 li.site-logo{ margin-right: 0px; }
| |
| 1292 | ||
| 1293 | ||
| 1294 | ||
| 1295 | /*fixing the menu allignement styles*/ | |
| 1296 | <?php if( is_numeric(options::get_value('header_settings', 'menu1_spacing'))):?>
| |
| 1297 | .header_style1:not(.crowd-layout) .primary-navigation > ul > li, | |
| 1298 | .header_style5:not(.crowd-layout) .primary-navigation > ul > li, | |
| 1299 | .crowd-simple-menu .primary-navigation > ul > li{
| |
| 1300 | margin-right: <?php echo options::get_value('header_settings', 'menu1_spacing'); ?>px!important;
| |
| 1301 | } | |
| 1302 | .header_style1:not(.crowd-layout) .primary-navigation > ul > li:last-child, | |
| 1303 | .header_style5:not(.crowd-layout) .primary-navigation > ul > li:last-child, | |
| 1304 | .crowd-simple-menu .primary-navigation > ul > li:last-child{
| |
| 1305 | margin-right: 15px !important; | |
| 1306 | } | |
| 1307 | <?php endif;?> | |
| 1308 | ||
| 1309 | <?php if(is_numeric(options::get_value('header_settings', 'menu2_spacing_left')) ):?>
| |
| 1310 | .header_style4 .primary-navigation > ul > li.left-logo-menu, | |
| 1311 | .crowd-double-menu .primary-navigation > ul > li.left-logo-menu{
| |
| 1312 | margin-right: <?php echo options::get_value('header_settings', 'menu2_spacing_left'); ?>px !important;
| |
| 1313 | } | |
| 1314 | <?php endif;?> | |
| 1315 | <?php if(is_numeric(options::get_value('header_settings', 'menu2_spacing_right')) ):?>
| |
| 1316 | .header_style4 .primary-navigation > ul > li.right-logo-menu, | |
| 1317 | .crowd-double-menu .primary-navigation > ul > li.right-logo-menu{
| |
| 1318 | margin-left: <?php echo options::get_value('header_settings', 'menu2_spacing_right'); ?>px !important;
| |
| 1319 | } | |
| 1320 | <?php endif;?> | |
| 1321 | } | |
| 1322 | ||
| 1323 | <?php | |
| 1324 | ||
| 1325 | $header_padding_top = options::get_value( 'header_settings' , 'header_padding_top' ); | |
| 1326 | $header_padding_bottom = options::get_value( 'header_settings' , 'header_padding_bottom' ); | |
| 1327 | ||
| 1328 | $header_padding_top_mobile = options::get_value( 'header_settings' , 'header_padding_top_mobile' ); | |
| 1329 | $header_padding_bottom_mobile = options::get_value( 'header_settings' , 'header_padding_bottom_mobile' ); | |
| 1330 | ||
| 1331 | $distance_before_footer_widgets = options::get_value( 'footer_settings' , 'distance_before_footer_widgets' ); | |
| 1332 | $footer_bottom_distance = options::get_value( 'footer_settings' , 'footer_bottom_distance' ); | |
| 1333 | $text_logo_padding = options::get_value( 'styling' , 'distance' ); | |
| 1334 | ||
| 1335 | ||
| 1336 | $content_padding = options::get_value( 'content_settings' , 'content_padding' ); | |
| 1337 | ||
| 1338 | $distance_before_slideshow = options::get_value( 'sliders' , 'distance_before_slideshow' ); | |
| 1339 | $distance_after_slideshow = options::get_value( 'sliders' , 'distance_after_slideshow' ); | |
| 1340 | ?> | |
| 1341 | @media only screen and (max-width: 640px) | |
| 1342 | {
| |
| 1343 | /*header padding for mobiles*/ | |
| 1344 | <?php | |
| 1345 | if(is_numeric($header_padding_top_mobile)){
| |
| 1346 | ?> header.site-header | |
| 1347 | {
| |
| 1348 | padding-top: <?php echo $header_padding_top_mobile; ?>px; | |
| 1349 | } | |
| 1350 | ||
| 1351 | <?php | |
| 1352 | } | |
| 1353 | ?> | |
| 1354 | <?php | |
| 1355 | if(is_numeric($header_padding_bottom_mobile)){
| |
| 1356 | ?> header.site-header | |
| 1357 | {
| |
| 1358 | padding-bottom: <?php echo $header_padding_bottom_mobile; ?>px; | |
| 1359 | } | |
| 1360 | ||
| 1361 | <?php | |
| 1362 | } | |
| 1363 | ?> | |
| 1364 | } | |
| 1365 | <?php | |
| 1366 | if(is_numeric($distance_after_slideshow)){?>
| |
| 1367 | .main-slideshow{
| |
| 1368 | margin-bottom: <?php echo $distance_after_slideshow;?>px; | |
| 1369 | } | |
| 1370 | <?php }?> | |
| 1371 | ||
| 1372 | @media only screen and (min-width: 641px) | |
| 1373 | {
| |
| 1374 | /*header padding for mobiles*/ | |
| 1375 | <?php | |
| 1376 | ||
| 1377 | if(is_numeric($header_padding_top)){ ?>
| |
| 1378 | header.site-header, .crowd-layout .site-header | |
| 1379 | {
| |
| 1380 | padding-top: <?php echo $header_padding_top; ?>px; | |
| 1381 | } | |
| 1382 | <?php }?> | |
| 1383 | <?php | |
| 1384 | if(is_numeric($distance_before_footer_widgets)){?>
| |
| 1385 | .footer-top-inner{
| |
| 1386 | padding-top: <?php echo $distance_before_footer_widgets;?>px; | |
| 1387 | } | |
| 1388 | <?php }?> | |
| 1389 | <?php | |
| 1390 | if(is_numeric($footer_bottom_distance)){?>
| |
| 1391 | .footer-bottom{
| |
| 1392 | padding-top: <?php echo $footer_bottom_distance;?>px; | |
| 1393 | padding-bottom: <?php echo $footer_bottom_distance;?>px; | |
| 1394 | } | |
| 1395 | <?php }?> | |
| 1396 | <?php | |
| 1397 | if(is_numeric($distance_before_slideshow)){?>
| |
| 1398 | .main-slideshow{
| |
| 1399 | padding-top: <?php echo $distance_before_slideshow;?>px; | |
| 1400 | } | |
| 1401 | <?php }?> | |
| 1402 | ||
| 1403 | <?php | |
| 1404 | if(is_numeric($content_padding)){?>
| |
| 1405 | .layout-width, .single-layout-width{
| |
| 1406 | padding-top: <?php echo $content_padding;?>px!important; | |
| 1407 | } | |
| 1408 | <?php }?> | |
| 1409 | <?php | |
| 1410 | if(is_numeric($text_logo_padding)){?>
| |
| 1411 | header .site-identity.site-logo | |
| 1412 | {
| |
| 1413 | padding-top: <?php echo $text_logo_padding; ?>px; | |
| 1414 | padding-bottom: <?php echo $text_logo_padding; ?>px; | |
| 1415 | } | |
| 1416 | <?php }?> | |
| 1417 | <?php | |
| 1418 | if(is_numeric($header_padding_bottom)){ ?>
| |
| 1419 | header.site-header, .crowd-layout .site-header | |
| 1420 | {
| |
| 1421 | padding-bottom: <?php echo $header_padding_bottom; ?>px; | |
| 1422 | } | |
| 1423 | <?php }?> | |
| 1424 | } | |
| 1425 | </style> | |
| 1426 | <?php | |
| 1427 | flo_get_custom_colors(); | |
| 1428 | } | |
| 1429 | } | |
| 1430 | /** | |
| 1431 | * render custom color styles | |
| 1432 | */ | |
| 1433 | if (!function_exists('flo_get_custom_colors')) {
| |
| 1434 | function flo_get_custom_colors() | |
| 1435 | {
| |
| 1436 | if (strlen(options::get_value('colors', 'menu_links_color'))) {
| |
| 1437 | $menu_links_color = options::get_value('colors', 'menu_links_color');
| |
| 1438 | } else {
| |
| 1439 | $menu_links_color = ''; | |
| 1440 | } | |
| 1441 | if (strlen(options::get_value('colors', 'submenu_background'))) {
| |
| 1442 | $submenu_background = options::get_value('colors', 'submenu_background');
| |
| 1443 | } else {
| |
| 1444 | $submenu_background = ''; | |
| 1445 | } | |
| 1446 | if (strlen(options::get_value('colors', 'background_color'))) {
| |
| 1447 | $background_color = options::get_value('colors', 'background_color');
| |
| 1448 | } else {
| |
| 1449 | $background_color = ''; | |
| 1450 | } | |
| 1451 | if (strlen(options::get_value('colors', 'content_text_color'))) {
| |
| 1452 | $content_text_color = options::get_value('colors', 'content_text_color');
| |
| 1453 | } else {
| |
| 1454 | $content_text_color = ''; | |
| 1455 | } | |
| 1456 | if (strlen(options::get_value('sliders', 'margin_below_sliders'))) {
| |
| 1457 | $margin_below_sliders = options::get_value('sliders', 'margin_below_sliders');
| |
| 1458 | } else {
| |
| 1459 | $margin_below_sliders = ''; | |
| 1460 | } | |
| 1461 | ||
| 1462 | if (strlen(options::get_value('colors', 'pretitle_color'))) {
| |
| 1463 | $pretitle_color = options::get_value('colors', 'pretitle_color');
| |
| 1464 | } else {
| |
| 1465 | $pretitle_color = ''; | |
| 1466 | } | |
| 1467 | if (strlen(options::get_value('colors', 'subtitle_color'))) {
| |
| 1468 | $subtitle_color = options::get_value('colors', 'subtitle_color');
| |
| 1469 | } else {
| |
| 1470 | $subtitle_color = ''; | |
| 1471 | } | |
| 1472 | if (strlen(options::get_value('colors', 'meta_share_pagination'))) {
| |
| 1473 | $meta_share_pagination = options::get_value('colors', 'meta_share_pagination');
| |
| 1474 | } else {
| |
| 1475 | $meta_share_pagination = ''; | |
| 1476 | } | |
| 1477 | if (strlen(options::get_value('colors', 'bottom_widget_background'))) {
| |
| 1478 | $bottom_widget_background = options::get_value('colors', 'bottom_widget_background');
| |
| 1479 | } else {
| |
| 1480 | $bottom_widget_background = ''; | |
| 1481 | } | |
| 1482 | if (strlen(options::get_value('colors', 'footer_bottom_widget_text'))) {
| |
| 1483 | $footer_bottom_widget_text = options::get_value('colors', 'footer_bottom_widget_text');
| |
| 1484 | } else {
| |
| 1485 | $footer_bottom_widget_text = ''; | |
| 1486 | } | |
| 1487 | if (strlen(options::get_value('colors', 'links_color'))) {
| |
| 1488 | $links_color = options::get_value('colors', 'links_color');
| |
| 1489 | } else {
| |
| 1490 | $links_color = ''; | |
| 1491 | } | |
| 1492 | if (strlen(options::get_value('colors', 'borders_color'))) {
| |
| 1493 | $borders_color = options::get_value('colors', 'borders_color');
| |
| 1494 | } else {
| |
| 1495 | $borders_color = ''; | |
| 1496 | } | |
| 1497 | ||
| 1498 | if (strlen(options::get_value('colors', 'borders_color'))) {
| |
| 1499 | $menu_links_hover_color = options::get_value('colors', 'menu_links_hover_color');
| |
| 1500 | } else {
| |
| 1501 | $menu_links_hover_color = ''; | |
| 1502 | } | |
| 1503 | ||
| 1504 | if (strlen(options::get_value('colors', 'submenu_hover'))) {
| |
| 1505 | $submenu_hover = options::get_value('colors', 'submenu_hover');
| |
| 1506 | } else {
| |
| 1507 | $submenu_hover = ''; | |
| 1508 | } | |
| 1509 | ?> | |
| 1510 | <style type="text/css"> | |
| 1511 | ||
| 1512 | ||
| 1513 | ||
| 1514 | .crowd-header-over .sticky-holder:not(.fixed) .primary-navigation .nav-menu>li>a{
| |
| 1515 | color:<?php echo options::get_value('colors', 'slideshow_menu_links_color');?>
| |
| 1516 | } | |
| 1517 | .crowd-layout .sticky-holder:not(.fixed) .primary-navigation > ul > li > a:hover{
| |
| 1518 | color:<?php echo options::get_value('colors', 'slideshow_menu_links_hover_color'); ?>
| |
| 1519 | } | |
| 1520 | ||
| 1521 | .primary-navigation ul li a:hover, .mobile-menu-inner ul li a:hover{
| |
| 1522 | color:<?php echo $submenu_hover;?> | |
| 1523 | } | |
| 1524 | .primary-navigation > ul > li > a:hover, .mobile-menu-inner > ul > li > a:hover{
| |
| 1525 | color:<?php echo $menu_links_hover_color;?> | |
| 1526 | } | |
| 1527 | .primary-navigation ul li a, .mobile-menu-inner li a, .menu-toggle i:before, .menu-toggle span{
| |
| 1528 | color:<?php echo $menu_links_color;?> | |
| 1529 | } | |
| 1530 | .primary-navigation ul li ul, .crowd-full-screen .children{
| |
| 1531 | background: <?php echo $submenu_background;?> | |
| 1532 | } | |
| 1533 | ||
| 1534 | ||
| 1535 | ||
| 1536 | .site-header, body, .primary-navigation ul, .post-pagination .next-post .inner, .post-pagination .prev-post .inner, | |
| 1537 | .crowd-layout .site-main,.crowd-layout .site-footer{
| |
| 1538 | background: <?php echo $background_color?>; | |
| 1539 | } | |
| 1540 | body, .post-title, .widget-title{
| |
| 1541 | color: <?php echo $content_text_color;?>; | |
| 1542 | } | |
| 1543 | .post-title .post-title-before{
| |
| 1544 | color: <?php echo $pretitle_color;?> | |
| 1545 | } | |
| 1546 | .post-title .post-title-after{
| |
| 1547 | color: <?php echo $subtitle_color;?> | |
| 1548 | } | |
| 1549 | .post-meta span a, .meta-wrap a, .meta-wrap:before, .pagination-wrapper .page-item, .pagination-wrapper .prev, .pagination-wrapper .next {
| |
| 1550 | color: <?php echo $meta_share_pagination;?> | |
| 1551 | } | |
| 1552 | .widget_socialicons .social a,.content .social a{
| |
| 1553 | color: <?php echo options::get_value('colors', 'social_icons_widget_color'); ?>;
| |
| 1554 | } | |
| 1555 | .widget-title{
| |
| 1556 | color: <?php echo options::get_value('colors', 'widgets_title_color'); ?>;
| |
| 1557 | } | |
| 1558 | .widget, .widget a{
| |
| 1559 | color: <?php echo options::get_value('colors', 'widgets_content_color'); ?>;
| |
| 1560 | } | |
| 1561 | ||
| 1562 | .footer-bottom{
| |
| 1563 | background: <?php echo $bottom_widget_background;?> | |
| 1564 | } | |
| 1565 | .footer-bottom, .footer-bottom a{
| |
| 1566 | color: <?php echo $footer_bottom_widget_text;?> | |
| 1567 | } | |
| 1568 | a{
| |
| 1569 | color: <?php echo $links_color;?> | |
| 1570 | } | |
| 1571 | .layout-width:before, .single-layout-width:before{
| |
| 1572 | border-top: 1px solid <?php echo $borders_color;?>; | |
| 1573 | } | |
| 1574 | .footer-top-inner{
| |
| 1575 | border-top: 1px solid <?php echo $borders_color;?>; | |
| 1576 | border-bottom: 1px solid <?php echo $borders_color;?>; | |
| 1577 | } | |
| 1578 | <?php if(isset($margin_below_sliders) && $margin_below_sliders != ''):?> | |
| 1579 | @media only screen and (min-width: 48.063em) {
| |
| 1580 | .full-width-slider .flo-slick-slider{
| |
| 1581 | margin-bottom: <?php echo $margin_below_sliders;?>px; | |
| 1582 | } | |
| 1583 | } | |
| 1584 | <?php endif;?> | |
| 1585 | </style> | |
| 1586 | <?php | |
| 1587 | } | |
| 1588 | ||
| 1589 | } | |
| 1590 | ||
| 1591 | ||
| 1592 | /** | |
| 1593 | * @return array - registered social profiles | |
| 1594 | */ | |
| 1595 | ||
| 1596 | function flo_get_available_social_services() | |
| 1597 | {
| |
| 1598 | ||
| 1599 | $available_social_services = array(); | |
| 1600 | $social_profiles = get_option('_social');
| |
| 1601 | ||
| 1602 | if (sizeof($social_profiles) && is_array($social_profiles)) {
| |
| 1603 | foreach ($social_profiles as $key => $s_profile) {
| |
| 1604 | if (strlen($s_profile['title'])) {
| |
| 1605 | $available_social_services[$s_profile['title']] = $s_profile['title']; | |
| 1606 | } | |
| 1607 | } | |
| 1608 | } | |
| 1609 | ||
| 1610 | ||
| 1611 | return $available_social_services; | |
| 1612 | } | |
| 1613 | function addhttp($url) {
| |
| 1614 | if (!preg_match("~^(?:f|ht)tps?://~i", $url) && (strtolower(substr($url, 0, 7)) != 'mailto:')) {
| |
| 1615 | $url = "http://" . $url; | |
| 1616 | } | |
| 1617 | return $url; | |
| 1618 | } | |
| 1619 | ||
| 1620 | if (!function_exists('flo_set_typography')) {
| |
| 1621 | /** | |
| 1622 | * returns the typography styles based on passed settings | |
| 1623 | * | |
| 1624 | * @param array $typography_settings - the array of settings. The keys are the same as the typography options name, and the value are elemets to which the fonts must be applied | |
| 1625 | * @return string | |
| 1626 | */ | |
| 1627 | function flo_set_typography($typography_settings = array()) | |
| 1628 | {
| |
| 1629 | ||
| 1630 | $typography_styles = ''; | |
| 1631 | ||
| 1632 | if (is_array($typography_settings) && sizeof($typography_settings)) {
| |
| 1633 | ||
| 1634 | $default_system_fonts = array( | |
| 1635 | "Cantarell, Tahoma, Verdana, Helvetica, sans-serif", | |
| 1636 | "'Unica One', Arial, Helvetica, sans-serif", | |
| 1637 | //"'Montserrat Subrayada', Arial, Helvetica, sans-serif", | |
| 1638 | 'Arial, Helvetica, sans-serif', | |
| 1639 | 'Times, Georgia, serif', | |
| 1640 | 'Verdana, Tahoma, sans-serif', | |
| 1641 | "'Century Gothic', Helvetica, Arial, sans-serif", | |
| 1642 | 'Helvetica, Arial, sans-serif', | |
| 1643 | 'Georgia, Times, serif', | |
| 1644 | "'Lucida Grande', 'Lucida Sans Unicode', Tahoma, Verdana, sans-serif", | |
| 1645 | 'Palatino, Georgia, serif', | |
| 1646 | 'Tahoma, Verdana, Helvetica, sans-serif', | |
| 1647 | 'Garamond, Palatino, Georgia, serif', | |
| 1648 | 'Courier, monospace', | |
| 1649 | "'Trebuchet MS', Tahoma, Helvetica, sans-serif", | |
| 1650 | "'Comic Sans MS', Arial, sans-serif", | |
| 1651 | 'Bookman, Palatino, Georgia, serif' | |
| 1652 | ); | |
| 1653 | ||
| 1654 | foreach ($typography_settings as $typography_option => $markup_elements) {
| |
| 1655 | ||
| 1656 | if (strlen(options::get_value('typography', $typography_option . '_font_size'))) {
| |
| 1657 | $font_size = ' font-size:' . options::get_value('typography', $typography_option . '_font_size') . 'px; ';
| |
| 1658 | } else {
| |
| 1659 | $font_size = ''; | |
| 1660 | } | |
| 1661 | ||
| 1662 | if (strlen(options::get_value('typography', $typography_option . '_font_letter_spacing')) && is_numeric(options::get_value('typography', $typography_option . '_font_letter_spacing'))) {
| |
| 1663 | $letter_spacing = ' letter-spacing:' . options::get_value('typography', $typography_option . '_font_letter_spacing') . 'px; ';
| |
| 1664 | } else {
| |
| 1665 | $letter_spacing = ''; | |
| 1666 | } | |
| 1667 | ||
| 1668 | if (strlen( trim(options::get_value('typography', $typography_option . '_font_family')) )) {
| |
| 1669 | ||
| 1670 | $font_fam_option = options::get_value('typography', $typography_option . '_font_family');
| |
| 1671 | ||
| 1672 | // usually we have this case when the fonts are loaded usin API KEY and we have several versions of the | |
| 1673 | // same font and font name is devided by font style by '|' i.e Acme | italic | |
| 1674 | if (strstr($font_fam_option, '|') !== false) {
| |
| 1675 | $family_exploded = explode('|', $font_fam_option);
| |
| 1676 | ||
| 1677 | $font_family_value = trim($family_exploded[0]); | |
| 1678 | if (!in_array($font_family_value, $default_system_fonts)) {
| |
| 1679 | // IF the current font is one of the default system fonts, then we will use them without \" (quotes) | |
| 1680 | $font_family_value = '"' . $font_family_value . '"'; | |
| 1681 | } | |
| 1682 | ||
| 1683 | $font_family = ' font-family: ' . $font_family_value . ' ; '; | |
| 1684 | ||
| 1685 | ||
| 1686 | } else {
| |
| 1687 | ||
| 1688 | $font_family_value = str_replace('+', ' ', rtrim(options::get_value('typography', $typography_option . '_font_family'), '&v1'));
| |
| 1689 | ||
| 1690 | if (!in_array($font_family_value, $default_system_fonts)) {
| |
| 1691 | // IF the current font is one of the default system fonts, then we will use them without \" (quotes) | |
| 1692 | $font_family_value = '"' . $font_family_value . '"'; | |
| 1693 | } | |
| 1694 | ||
| 1695 | $font_family = ' font-family: ' . $font_family_value . ' ; '; | |
| 1696 | ||
| 1697 | } | |
| 1698 | ||
| 1699 | ||
| 1700 | } else {
| |
| 1701 | $font_family = ''; | |
| 1702 | } | |
| 1703 | ||
| 1704 | if (strlen(options::get_value('typography', $typography_option . '_font_weight'))) {
| |
| 1705 | $font_weight = ' font-weight:' . options::get_value('typography', $typography_option . '_font_weight') . '; ';
| |
| 1706 | } else {
| |
| 1707 | $font_weight = ''; | |
| 1708 | } | |
| 1709 | ||
| 1710 | if (strlen(options::get_value('typography', $typography_option . '_font_style'))) {
| |
| 1711 | $font_style = ' font-style:' . options::get_value('typography', $typography_option . '_font_style') . '; ';
| |
| 1712 | } else {
| |
| 1713 | $font_style = ''; | |
| 1714 | } | |
| 1715 | ||
| 1716 | $typography_styles .= ' ' . $markup_elements . '{ ' . $font_size . $font_family . $font_weight . $font_style . $letter_spacing . '}' . ' ';
| |
| 1717 | } | |
| 1718 | } | |
| 1719 | /* Start Option for mobile devices*/ | |
| 1720 | $typography_styles .= '@media only screen and (max-width: 768px) {';
| |
| 1721 | foreach ($typography_settings as $typography_option => $markup_elements) {
| |
| 1722 | if (strlen(options::get_value('typography', $typography_option . '_font_size_mobile'))) {
| |
| 1723 | $font_size = ' font-size:' . options::get_value('typography', $typography_option . '_font_size_mobile') . 'px; ';
| |
| 1724 | } else {
| |
| 1725 | $font_size = ''; | |
| 1726 | } | |
| 1727 | ||
| 1728 | if (strlen(options::get_value('typography', $typography_option . '_font_letter_spacing_mobile')) && is_numeric(options::get_value('typography', $typography_option . '_font_letter_spacing_mobile'))) {
| |
| 1729 | $letter_spacing_mobile = ' letter-spacing:' . options::get_value('typography', $typography_option . '_font_letter_spacing_mobile') . 'px; ';
| |
| 1730 | } else {
| |
| 1731 | $letter_spacing_mobile = ''; | |
| 1732 | } | |
| 1733 | ||
| 1734 | $typography_styles .= ' ' . $markup_elements . '{ ' . $font_size . $letter_spacing_mobile .'}' . ' ';
| |
| 1735 | } | |
| 1736 | $typography_styles .= '}'; | |
| 1737 | /* End Option for mobile devices*/ | |
| 1738 | ||
| 1739 | return $typography_styles; | |
| 1740 | } | |
| 1741 | ||
| 1742 | } | |
| 1743 | /** | |
| 1744 | * render social icons | |
| 1745 | */ | |
| 1746 | if (!function_exists('flo_get_social_icons')) {
| |
| 1747 | function flo_get_social_icons($enabled_services = array('facebook', 'twitter', 'gplus', 'yahoo', 'dribbble', 'linkedin', 'vimeo', 'youtube', 'tumblr', 'delicious', 'flickr', 'instagram', 'pinterest', 'skype', 'email',
| |
| 1748 | 'rss'), $no_icons = false, $add_search = false) | |
| 1749 | {
| |
| 1750 | ||
| 1751 | if (!(is_array($enabled_services) && sizeof($enabled_services))) {
| |
| 1752 | $enabled_services = array(); | |
| 1753 | } | |
| 1754 | ||
| 1755 | // the following social profiles have font icons support | |
| 1756 | $default_supported_profiles = array('facebook', 'twitter', 'gplus', 'yahoo', 'dribbble', 'linkedin', 'vimeo', 'youtube', 'tumblr', 'delicious', 'flickr', 'instagram', 'pinterest', 'skype', 'email', 'rss');
| |
| 1757 | ||
| 1758 | $social_profiles = get_option('_social');
| |
| 1759 | ||
| 1760 | ob_start(); | |
| 1761 | ob_clean(); | |
| 1762 | ||
| 1763 | $social_icons_content = ''; | |
| 1764 | ||
| 1765 | if (!$no_icons && sizeof($social_profiles) && is_array($social_profiles)) {
| |
| 1766 | ||
| 1767 | //deb::e($social_profiles); | |
| 1768 | ||
| 1769 | foreach ($social_profiles as $key => $s_profile) {
| |
| 1770 | ||
| 1771 | //if(isset($s_profile['title']) && in_array( trim($s_profile['title']), $enabled_services) ){
| |
| 1772 | // backwards compatibility | |
| 1773 | ||
| 1774 | $profile_url = $s_profile['url']; | |
| 1775 | ||
| 1776 | if (in_array(trim($s_profile['title']), $enabled_services)) {
| |
| 1777 | ||
| 1778 | ||
| 1779 | if (isset($s_profile['icon_image'])) {
| |
| 1780 | $icon_img_src = $s_profile['icon_image']; | |
| 1781 | } else {
| |
| 1782 | $icon_img_src = ''; | |
| 1783 | } | |
| 1784 | ||
| 1785 | switch (trim($s_profile['title'])) {
| |
| 1786 | case 'facebook': | |
| 1787 | // backward compatibility: if user entered just FB profile name, we will built the real URL below | |
| 1788 | if (!cosmo_isValidURL($profile_url) && strlen($profile_url)) {
| |
| 1789 | $profile_url = 'http://facebook.com/people/@/' . $profile_url; | |
| 1790 | } | |
| 1791 | ||
| 1792 | break; | |
| 1793 | ||
| 1794 | case 'twitter': | |
| 1795 | // backward compatibility: if user entered just Twitter profile name, we will built the real URL below | |
| 1796 | if (!cosmo_isValidURL($profile_url) && strlen($profile_url)) {
| |
| 1797 | $profile_url = 'http://twitter.com/' . $profile_url; | |
| 1798 | } | |
| 1799 | ||
| 1800 | break; | |
| 1801 | ||
| 1802 | ||
| 1803 | } | |
| 1804 | ||
| 1805 | if (!isset($s_profile['icon_image']) || (isset($s_profile['icon_image']) && trim($s_profile['icon_image']) == '') | |
| 1806 | && isset($s_profile['title']) && in_array(trim(strtolower($s_profile['title'])), $default_supported_profiles) | |
| 1807 | ) {
| |
| 1808 | // use font icons for suported services if customicon is not uploaded | |
| 1809 | $icon = '<i class="icon-' . trim(strtolower($s_profile['title'])) . '"></i>'; | |
| 1810 | } else if (isset($s_profile['icon_image_hover']) && strlen($s_profile['icon_image_hover'])) {
| |
| 1811 | ||
| 1812 | // for icons that have image for rol over we add a specific class "flo-social-hover" and data atributes for hove and original image. | |
| 1813 | $icon = '<i><img src="' . $icon_img_src . '" data-imghover="' . $s_profile['icon_image_hover'] . '" data-imgoriginal="' . $icon_img_src . '" alt="' . $s_profile['title'] . '" class="flo-social-hover" /></i>'; | |
| 1814 | } else {
| |
| 1815 | $icon = '<i><img src="' . $icon_img_src . '" alt="' . $s_profile['title'] . '" /></i>'; | |
| 1816 | } | |
| 1817 | ||
| 1818 | if (strlen(trim($profile_url))) {
| |
| 1819 | ?> | |
| 1820 | <a href="<?php echo addhttp($profile_url) ?>" target="_blank" class="<?php echo $s_profile['title']; ?> hover-menu"><?php echo $icon; ?></a> | |
| 1821 | <?php | |
| 1822 | } | |
| 1823 | ||
| 1824 | } | |
| 1825 | ||
| 1826 | } | |
| 1827 | } | |
| 1828 | ||
| 1829 | $social_icons_content = ob_get_clean(); | |
| 1830 | ||
| 1831 | if ($add_search) { // append search
| |
| 1832 | $social_icons_content .= '<a href="javascript:void(0);" class="the-header-search"> <i class="icon-search"></i> </a>'; | |
| 1833 | } | |
| 1834 | if (strlen(trim($social_icons_content))) {
| |
| 1835 | ?> | |
| 1836 | <div class="social-links"> | |
| 1837 | <div class="social"> | |
| 1838 | <?php echo $social_icons_content; ?> | |
| 1839 | </div> | |
| 1840 | </div> | |
| 1841 | <?php | |
| 1842 | if ($add_search) { // append search
| |
| 1843 | ?> | |
| 1844 | <div class="header-serch"> | |
| 1845 | <form action="<?php echo home_url(); ?>/" method="get" id="searchform-header"> | |
| 1846 | <fieldset> | |
| 1847 | <input class="input" name="s" type="text" id="keywords1" value="" placeholder="search"> | |
| 1848 | <button><i class="icon-search"></i></button> | |
| 1849 | <i class="icon-close"></i> | |
| 1850 | </fieldset> | |
| 1851 | </form> | |
| 1852 | </div> | |
| 1853 | <?php | |
| 1854 | } | |
| 1855 | } | |
| 1856 | ||
| 1857 | } | |
| 1858 | ||
| 1859 | } | |
| 1860 | ||
| 1861 | ||
| 1862 | /* | |
| 1863 | * List Blog view width | |
| 1864 | * Single blog post width | |
| 1865 | */ | |
| 1866 | if (!function_exists('cosmo_get_post_list_width')) {
| |
| 1867 | function cosmo_get_post_list_width($args) | |
| 1868 | {
| |
| 1869 | ||
| 1870 | $single_blog_post_max_width = options::get_value('layout', 'single_blog_post_max_width');
| |
| 1871 | ?> | |
| 1872 | <style type="text/css"> | |
| 1873 | ||
| 1874 | <?php if(is_numeric($single_blog_post_max_width)){?>
| |
| 1875 | .post-article .post-article-inner | |
| 1876 | {
| |
| 1877 | max-width: <?php echo $single_blog_post_max_width."px";?>; | |
| 1878 | } | |
| 1879 | <?php }?> | |
| 1880 | ||
| 1881 | <?php | |
| 1882 | // for the submenu use font with 1 pixels smaller | |
| 1883 | $navigation_font_size = options::get_value( 'typography' , 'menu_links_font_font_size' ); | |
| 1884 | $submenu_nav_font_size = $navigation_font_size - 1; | |
| 1885 | ?> | |
| 1886 | ||
| 1887 | @media screen and (min-width: 768px) {
| |
| 1888 | .main-navigation .menu ul.children a{ font-size: <?php echo $submenu_nav_font_size; ?>px ; }
| |
| 1889 | } | |
| 1890 | </style> | |
| 1891 | <?php } | |
| 1892 | } ?> | |
| 1893 | <?php /** | |
| 1894 | * render attached images gallery | |
| 1895 | */ | |
| 1896 | if (!function_exists('cosmo_get_post_img_slideshow')) {
| |
| 1897 | function cosmo_get_post_img_slideshow($args) | |
| 1898 | {
| |
| 1899 | ||
| 1900 | extract($args); // extract passed arguments | |
| 1901 | ||
| 1902 | // add any new arguments here | |
| 1903 | $default_args = array( | |
| 1904 | 'post_id' => 0, | |
| 1905 | 'size' => array('width' => 750, 'height' => 500),
| |
| 1906 | 'show_nav_thumbs' => true, | |
| 1907 | 'main_container_class' => 'royalSlider', | |
| 1908 | 'slide_class' => '' | |
| 1909 | ||
| 1910 | ); | |
| 1911 | ||
| 1912 | foreach ($args as $entry_key => $entry_value) {
| |
| 1913 | $default_args[$entry_key] = $entry_value; | |
| 1914 | } | |
| 1915 | extract($default_args); | |
| 1916 | ||
| 1917 | /*check the meta data where the attached image ids are stored*/ | |
| 1918 | ||
| 1919 | if (metadata_exists('post', $post_id, '_post_image_gallery')) {
| |
| 1920 | ||
| 1921 | $product_image_gallery = get_post_meta($post_id, '_post_image_gallery', true); | |
| 1922 | ||
| 1923 | $img_id_array = array_filter(explode(',', $product_image_gallery));
| |
| 1924 | } | |
| 1925 | ||
| 1926 | ||
| 1927 | if (isset($img_id_array) && is_array($img_id_array)) {
| |
| 1928 | foreach ($img_id_array as $value) {
| |
| 1929 | $attachments[$value] = $value; // create attachments array in hte format that will work for us | |
| 1930 | } | |
| 1931 | } | |
| 1932 | ||
| 1933 | ||
| 1934 | if (isset($attachments) && count($attachments) > 0) {
| |
| 1935 | $pretty_colection_id = mt_rand(0, 9999); | |
| 1936 | ||
| 1937 | ||
| 1938 | $counter = 0; ?> | |
| 1939 | ||
| 1940 | <div class=" single-post-gallery not-main-slideshow rsDefault <?php if (isset($main_container_class)) {
| |
| 1941 | echo $main_container_class; | |
| 1942 | } | |
| 1943 | if (!$show_nav_thumbs) {
| |
| 1944 | echo ' no-thumbs '; | |
| 1945 | } ?> " style=" height:<?php echo $size['height']; // we need to set this height to have the slider size as we want ?>px; "> | |
| 1946 | <?php | |
| 1947 | foreach ($attachments as $att_id => $attachment) {
| |
| 1948 | ||
| 1949 | ?> | |
| 1950 | <div class="rsContent <?php if (isset($slide_class)) {
| |
| 1951 | echo $slide_class; | |
| 1952 | } ?> "> | |
| 1953 | <div class="img-holder"> | |
| 1954 | <?php | |
| 1955 | $full_img_url = wp_get_attachment_url($att_id); | |
| 1956 | ||
| 1957 | $thumbnail_url = aq_resize($full_img_url, $size['width'], $size['height'], false, false); //resize img, Return an array containing url, width, and height. | |
| 1958 | $src = $thumbnail_url[0]; // use original img src | |
| 1959 | ?> | |
| 1960 | <!-- lazy load img --> | |
| 1961 | <a class="rsImg" href="<?php echo $src; ?>" data-rsBigImg="<?php echo $full_img_url; ?>"></a> | |
| 1962 | ||
| 1963 | <?php if ($show_nav_thumbs) { ?>
| |
| 1964 | <?php | |
| 1965 | $thumbnail_url = aq_resize($full_img_url, 150, 150, true, false); //crop img, | |
| 1966 | ?> | |
| 1967 | <div class="rsTmb"><img src="<?php echo $thumbnail_url[0]; ?>" width="<?php echo $thumbnail_url[1];?>" height="<?php echo $thumbnail_url[2];?>" alt=""/></div> | |
| 1968 | <?php } ?> | |
| 1969 | ||
| 1970 | ||
| 1971 | </div> | |
| 1972 | </div> | |
| 1973 | <?php } ?> | |
| 1974 | </div> | |
| 1975 | ||
| 1976 | <?php | |
| 1977 | } | |
| 1978 | } | |
| 1979 | ||
| 1980 | } | |
| 1981 | ||
| 1982 | /** | |
| 1983 | * params: | |
| 1984 | * int - $post_id - the ID of the post for which we wsant to retrieve the categories | |
| 1985 | * bool - $only_first_cat - return only first categ or all of them | |
| 1986 | * string - $taxonomy - the name of the wanted taxonomy, 'category' by default , other values may be 'post_tag' for standard posts or something ele for custom posts | |
| 1987 | * string - $margin_elem_start - it shuld be a html element that will show up before each category | |
| 1988 | * string - $margin_elem_end - it shuld be a html element that will show up after each category | |
| 1989 | * string - $delimiter - the string between the taxonomies | |
| 1990 | * string - $a_class - the class that is used for the anchor that surrounds the taxonomies | |
| 1991 | * string - $no_link - use or not links around the taxonomies | |
| 1992 | */ | |
| 1993 | if (!function_exists('flo_get_post_taxonomies')) {
| |
| 1994 | function flo_get_post_taxonomies($post_id, $only_first_cat = false, $taxonomy = 'category', $margin_elem_start = '', $margin_elem_end = '', $delimiter = ', ', $a_class = '', $no_link = false) | |
| 1995 | {
| |
| 1996 | ||
| 1997 | ||
| 1998 | $cat = ''; | |
| 1999 | $categories = wp_get_post_terms($post_id, $taxonomy); | |
| 2000 | if (!empty($categories)) {
| |
| 2001 | ||
| 2002 | $ind = 1; | |
| 2003 | foreach ($categories as $category) {
| |
| 2004 | $categ = get_term($category->term_id, $taxonomy); | |
| 2005 | if ($ind != count($categories) && !$only_first_cat) {
| |
| 2006 | $cat_delimiter = $delimiter; | |
| 2007 | } else {
| |
| 2008 | $cat_delimiter = ''; | |
| 2009 | } | |
| 2010 | ||
| 2011 | if ($no_link) {
| |
| 2012 | $cat .= $margin_elem_start . $categ->name . $cat_delimiter . $margin_elem_end; | |
| 2013 | } else {
| |
| 2014 | $cat .= $margin_elem_start . '<a href="' . get_category_link($category) . '" class="' . $a_class . '">' . $categ->name . $cat_delimiter . '</a>' . $margin_elem_end; | |
| 2015 | } | |
| 2016 | ||
| 2017 | ||
| 2018 | if ($only_first_cat) {
| |
| 2019 | break; | |
| 2020 | } | |
| 2021 | ||
| 2022 | ||
| 2023 | $ind++; | |
| 2024 | } | |
| 2025 | ||
| 2026 | ||
| 2027 | //$cat = __('in','flotheme').' '. $cat;
| |
| 2028 | } | |
| 2029 | ||
| 2030 | return $cat . ' '; | |
| 2031 | } | |
| 2032 | } | |
| 2033 | ||
| 2034 | /** | |
| 2035 | * render a link to the post's post format archive, the link has a specific class depending on hte post format | |
| 2036 | * params: | |
| 2037 | * int - $post_id - the ID of the post for which we want to retrieve the post format | |
| 2038 | */ | |
| 2039 | ||
| 2040 | if (!function_exists('cosmo_get_post_format_link')) {
| |
| 2041 | function cosmo_get_post_format_link($post_id) | |
| 2042 | {
| |
| 2043 | ||
| 2044 | $result = ''; | |
| 2045 | $format = get_post_format($post_id); | |
| 2046 | $format_link = get_post_format_link($format); | |
| 2047 | if (!strlen($format_link)) {
| |
| 2048 | $format_link = "javascript:void(0);"; | |
| 2049 | } | |
| 2050 | ||
| 2051 | switch ($format) {
| |
| 2052 | case 'video': | |
| 2053 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-video"></i></a>'; | |
| 2054 | break; | |
| 2055 | case 'image': | |
| 2056 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-image"></i></a>'; | |
| 2057 | break; | |
| 2058 | case 'audio': | |
| 2059 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-audio"></i></a>'; | |
| 2060 | break; | |
| 2061 | case 'link': | |
| 2062 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-attachment"></i></a>'; | |
| 2063 | break; | |
| 2064 | case 'gallery': | |
| 2065 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-gallery"></i></a>'; | |
| 2066 | break; | |
| 2067 | case 'quote': | |
| 2068 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-quote"></i></a>'; | |
| 2069 | break; | |
| 2070 | default: | |
| 2071 | $result .= '<a class="entry-format" href="' . $format_link . '"><i class="icon-standard"></i></a>'; | |
| 2072 | break; | |
| 2073 | } | |
| 2074 | ||
| 2075 | return $result; | |
| 2076 | } | |
| 2077 | } | |
| 2078 | ||
| 2079 | ||
| 2080 | /** | |
| 2081 | * retrieves the post date in the format specified in the theme settings | |
| 2082 | * params: | |
| 2083 | * int - $post_id - the ID of the post for which we want to retrieve the post format | |
| 2084 | */ | |
| 2085 | ||
| 2086 | if (!function_exists('flo_get_post_date')) {
| |
| 2087 | function flo_get_post_date($post_id) | |
| 2088 | {
| |
| 2089 | if (options::logic('blog_post', 'time')) {
| |
| 2090 | $post_date = human_time_diff(get_the_time('U', $post_id), current_time('timestamp')) . ' ' . __('ago', 'flotheme');
| |
| 2091 | } else {
| |
| 2092 | $post_date = date_i18n(get_option('date_format'), get_the_time('U', $post_id));
| |
| 2093 | } | |
| 2094 | ||
| 2095 | return $post_date . ' '; | |
| 2096 | } | |
| 2097 | } | |
| 2098 | ||
| 2099 | ||
| 2100 | /** | |
| 2101 | * check if a given string is a valid URL | |
| 2102 | */ | |
| 2103 | //if ( ! function_exists( 'cosmo_isValidURL' ) ) {
| |
| 2104 | function cosmo_isValidURL($url) | |
| 2105 | {
| |
| 2106 | return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
| |
| 2107 | } | |
| 2108 | ||
| 2109 | //} | |
| 2110 | ||
| 2111 | /** | |
| 2112 | * render post meta | |
| 2113 | */ | |
| 2114 | if (!function_exists('cosmo_post_meta')) {
| |
| 2115 | function cosmo_post_meta($post) | |
| 2116 | {
| |
| 2117 | global $wp_query; | |
| 2118 | ?> | |
| 2119 | <div class="post-meta-container"> | |
| 2120 | <ul class="post-meta"> | |
| 2121 | <li><?php echo cosmo_get_post_date($post->ID); ?></li> | |
| 2122 | <li><a href="<?php echo get_author_posts_url($post->post_author) ?>"> | |
| 2123 | <?php echo get_the_author_meta('display_name', $post->post_author); ?>
| |
| 2124 | </a> | |
| 2125 | </li> | |
| 2126 | ||
| 2127 | <?php | |
| 2128 | if (comments_open($post->ID)) {
| |
| 2129 | $comments_label = __('comments', 'flotheme');
| |
| 2130 | if (options::logic('blog_post', 'fb_comments')) {
| |
| 2131 | ?> | |
| 2132 | <li class="meta-elem cosmo-comments" title=""><a href="<?php echo get_comments_link($post->ID); ?>"> | |
| 2133 | <fb:comments-count href="<?php echo get_permalink($post->ID) ?>"></fb:comments-count> <?php echo $comments_label; ?></a></li><?php | |
| 2134 | } else {
| |
| 2135 | ||
| 2136 | if (get_comments_number($post->ID) == 1) {
| |
| 2137 | $comments_label = __('comment', 'flotheme');
| |
| 2138 | } | |
| 2139 | ?> | |
| 2140 | <li class="meta-elem cosmo-comments" title="<?php echo get_comments_number($post->ID); | |
| 2141 | echo ' ' . $comments_label; ?>"><a href="<?php echo get_comments_link($post->ID) ?>"> <?php echo get_comments_number($post->ID) . ' ' . $comments_label ?> </a></li><?php | |
| 2142 | } | |
| 2143 | } | |
| 2144 | ?> | |
| 2145 | ||
| 2146 | <?php if (!is_page()) { ?>
| |
| 2147 | <?php | |
| 2148 | $tags = wp_get_post_terms($post->ID, 'post_tag'); | |
| 2149 | ||
| 2150 | if (!empty($tags)) {
| |
| 2151 | ?> | |
| 2152 | <li class="meta-elem"> | |
| 2153 | ||
| 2154 | <i class="icon-tag"></i> | |
| 2155 | <ul class="b_tag"> | |
| 2156 | <?php | |
| 2157 | ||
| 2158 | echo flo_get_post_taxonomies($post->ID, $only_first_cat = false, $taxonomy = 'post_tag', $margin_elem_start = '<li>', $margin_elem_end = '</li> ', $delimiter = ','); | |
| 2159 | ||
| 2160 | ?> | |
| 2161 | </ul> | |
| 2162 | ||
| 2163 | </li> | |
| 2164 | <?php } ?> | |
| 2165 | <li class="meta-elem"> | |
| 2166 | <?php | |
| 2167 | $categories = wp_get_post_terms($post->ID, 'category'); | |
| 2168 | if (!empty($categories)) {
| |
| 2169 | ?> | |
| 2170 | <i class="icon-category"></i> | |
| 2171 | <ul class="category"> | |
| 2172 | <?php | |
| 2173 | echo flo_get_post_taxonomies($post->ID, $only_first_cat = false, $taxonomy = 'category', $margin_elem_start = '<li>', $margin_elem_end = '</li> ', $delimiter = ','); | |
| 2174 | ?> | |
| 2175 | </ul> | |
| 2176 | <?php | |
| 2177 | } | |
| 2178 | ?> | |
| 2179 | </li> | |
| 2180 | <?php } ?> | |
| 2181 | ||
| 2182 | </ul> | |
| 2183 | </div> | |
| 2184 | ||
| 2185 | <?php | |
| 2186 | } | |
| 2187 | } | |
| 2188 | ||
| 2189 | ||
| 2190 | /** | |
| 2191 | * Cosmo loop | |
| 2192 | */ | |
| 2193 | if (!function_exists('cosmo_loop')) {
| |
| 2194 | function cosmo_loop($template, $column_class = 'small-12 large-9 columns', $side = '') | |
| 2195 | {
| |
| 2196 | global $wp_query, $massonry_class, $taxonomy, $post, $custom_query, $page_id, $i,$nr_cols,$count_posts,$the_query,$last; | |
| 2197 | $custom_query = $wp_query; | |
| 2198 | $the_query = $wp_query; | |
| 2199 | ||
| 2200 | // echo "<pre>"; | |
| 2201 | // var_dump($wp_query);die; | |
| 2202 | ||
| 2203 | $enable_massonry = false; | |
| 2204 | $i = 0; | |
| 2205 | ||
| 2206 | if ($template == 'blog_page') {
| |
| 2207 | $view_type = options::get_value('content_settings', 'blog_listing_layout');
| |
| 2208 | $grid_cols = options::get_value('content_settings', 'blog_grid_layout');
| |
| 2209 | } else {
| |
| 2210 | $view_type = options::get_value('content_settings', 'archive_listing_layout');
| |
| 2211 | $grid_cols = options::get_value('content_settings', 'archive_grid_layout');
| |
| 2212 | } | |
| 2213 | global $grid_class, $view_type_custom, $block_width; | |
| 2214 | ||
| 2215 | // set the blog width for grid and thumb view | |
| 2216 | if ( strlen(options::get_value('content_settings', 'blog_grid_layout')) != '') {
| |
| 2217 | if ($grid_cols == 'grid1') {
| |
| 2218 | $block_width = ' small-12 large-6 '; | |
| 2219 | $nr_cols = 2; | |
| 2220 | } elseif ($grid_cols == 'grid2') {
| |
| 2221 | $block_width = ' small-12 large-4 '; | |
| 2222 | $nr_cols = 3; | |
| 2223 | }elseif ($grid_cols == 'grid3') {
| |
| 2224 | $block_width = ' small-13 large-3 '; | |
| 2225 | $nr_cols = 4; | |
| 2226 | } | |
| 2227 | ||
| 2228 | } else {
| |
| 2229 | $block_width = ' small-12 large-3 '; | |
| 2230 | $nr_cols = 3; | |
| 2231 | } | |
| 2232 | ||
| 2233 | // for grid-50_50 view type we will force 2 columns | |
| 2234 | if('grid-50_50' == $view_type){
| |
| 2235 | $nr_cols = 2; | |
| 2236 | $block_width = ' small-12 large-6 '; | |
| 2237 | } | |
| 2238 | ||
| 2239 | $view_type_custom = $view_type; | |
| 2240 | if (count($wp_query->posts) > 0) {
| |
| 2241 | ||
| 2242 | if (strpos($view_type, 'list') !== false) { // if any of the list view
| |
| 2243 | ?> | |
| 2244 | <?php | |
| 2245 | foreach ($wp_query->posts as $index => $post) {
| |
| 2246 | $wp_query->the_post(); | |
| 2247 | $template_name = 'floshortcodes/cosmo-' . $view_type . '.php'; // in order for this to work properly you should have the templates name having the view type name. | |
| 2248 | include(locate_template($template_name)); | |
| 2249 | } | |
| 2250 | get_template_part('pagination');
| |
| 2251 | ?> | |
| 2252 | <?php | |
| 2253 | } else {
| |
| 2254 | if (!(isset($gutter_class) && strlen($gutter_class))) {
| |
| 2255 | $gutter_class = 'no-gutter'; | |
| 2256 | } | |
| 2257 | ?> | |
| 2258 | <?php | |
| 2259 | $massonry_class = ''; | |
| 2260 | $enable_massonry = true; | |
| 2261 | $i = 1; | |
| 2262 | $counter = 1; | |
| 2263 | $count_posts = count($wp_query->posts); | |
| 2264 | foreach ($wp_query->posts as $index => $post) {
| |
| 2265 | $wp_query->the_post(); | |
| 2266 | if($post->post_type == 'video'){
| |
| 2267 | $taxonomy = 'video-category'; | |
| 2268 | }elseif($post->post_type == 'gallery'){
| |
| 2269 | $taxonomy = 'gallery-category'; | |
| 2270 | }else{
| |
| 2271 | $taxonomy = 'category'; | |
| 2272 | } | |
| 2273 | $template_name = 'floshortcodes/' . $view_type . '.php'; // in order for this to work properly you should have the templates name having the view type name. | |
| 2274 | include(locate_template($template_name)); | |
| 2275 | $i++; | |
| 2276 | $global_count = get_option('posts_per_page',true);
| |
| 2277 | $counter++; | |
| 2278 | ||
| 2279 | if ($counter == (int)$global_count){
| |
| 2280 | $last = true; | |
| 2281 | }else{
| |
| 2282 | $last = false; | |
| 2283 | } | |
| 2284 | } | |
| 2285 | ?> | |
| 2286 | <!-- --><?php | |
| 2287 | get_template_part('pagination');
| |
| 2288 | // ?> | |
| 2289 | <?php | |
| 2290 | } | |
| 2291 | if ($enable_massonry) {
| |
| 2292 | wp_localize_script('functions', 'enable_massonry', '1');
| |
| 2293 | } else {
| |
| 2294 | wp_localize_script('functions', 'enable_massonry', '0');
| |
| 2295 | } | |
| 2296 | ||
| 2297 | wp_reset_postdata(); /* Restore original Post Data */ | |
| 2298 | } else {
| |
| 2299 | get_template_part('loop', '404');
| |
| 2300 | } | |
| 2301 | } | |
| 2302 | } | |
| 2303 | ||
| 2304 | ||
| 2305 | /** | |
| 2306 | * Title : Aqua Resizer | |
| 2307 | * Description : this function will return the image size that will be passed to aq_resize function | |
| 2308 | * | |
| 2309 | * | |
| 2310 | * @param string $size_name - (required) the name of the size option, for example 'single_cropped' | |
| 2311 | * @param int $width_or_height - (not required) specifyes what demention we want to get, the width or the height of the image (default - width) | |
| 2312 | * | |
| 2313 | * @return str|array | |
| 2314 | *****/ | |
| 2315 | ||
| 2316 | function get_aqua_size($size_name, $width_or_height = 'width', $option = 'imagesizes') | |
| 2317 | {
| |
| 2318 | $result = options::get_value($option, $size_name . '_' . $width_or_height); | |
| 2319 | ||
| 2320 | if (is_numeric(trim($result))) {
| |
| 2321 | return trim($result); | |
| 2322 | } else {
| |
| 2323 | /*if the option is empty or not numeric for some reason, we return the default*/ | |
| 2324 | return options::$default[$option][$size_name . '_' . $width_or_height]; | |
| 2325 | } | |
| 2326 | } | |
| 2327 | ||
| 2328 | /** | |
| 2329 | * Description : this function will return the class name for the blocks depending on the input (number of columns we want to have) | |
| 2330 | * | |
| 2331 | * | |
| 2332 | * @param int $arabic - number of columns we want to have | |
| 2333 | * | |
| 2334 | * @return str | |
| 2335 | *****/ | |
| 2336 | if (!function_exists('cosmo_columns_arabic_to_chars')) {
| |
| 2337 | function cosmo_columns_arabic_to_chars($arabic) | |
| 2338 | {
| |
| 2339 | $words_full_width = array(0 => 'small-12 medium-12', 1 => 'small-12 medium-12', 2 => 'small-12 medium-6', 3 => 'small-12 medium-4', 4 => 'small-12 medium-3', 5 => 'small-12 medium-3', 6 => 'small-12 medium-2', | |
| 2340 | 7 => 'small-12 medium-2', 8 => 'small-12 medium-12', 9 => 'small-12 medium-12', 10 => 'small-12 medium-12', 11 => 'small-12 medium-12', 12 => 'small-12 medium-12'); | |
| 2341 | return $words_full_width[$arabic]; | |
| 2342 | } | |
| 2343 | } | |
| 2344 | ||
| 2345 | ||
| 2346 | if (!function_exists('hex2rgb')) {
| |
| 2347 | function hex2rgb($hex) | |
| 2348 | {
| |
| 2349 | $hex = str_replace("#", "", $hex);
| |
| 2350 | ||
| 2351 | if (strlen($hex) == 3) {
| |
| 2352 | $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); | |
| 2353 | $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); | |
| 2354 | $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); | |
| 2355 | } else {
| |
| 2356 | $r = hexdec(substr($hex, 0, 2)); | |
| 2357 | $g = hexdec(substr($hex, 2, 2)); | |
| 2358 | $b = hexdec(substr($hex, 4, 2)); | |
| 2359 | } | |
| 2360 | //$rgb = array($r, $g, $b); | |
| 2361 | $rgb = $r . ',' . $g . ',' . $b . ', '; | |
| 2362 | ||
| 2363 | //return implode(",", $rgb); // returns the rgb values separated by commas
| |
| 2364 | return $rgb; // returns an array with the rgb values | |
| 2365 | } | |
| 2366 | } | |
| 2367 | ||
| 2368 | /** | |
| 2369 | * cosmo_get_post_types_hc | |
| 2370 | */ | |
| 2371 | if (!function_exists('cosmo_get_post_types_hc')) {
| |
| 2372 | /** | |
| 2373 | * Description : this function will return an array of registered custom post types | |
| 2374 | * | |
| 2375 | * @return array | |
| 2376 | *****/ | |
| 2377 | function cosmo_get_post_types_hc() | |
| 2378 | {
| |
| 2379 | //of course it can be done via get_post_types, but for some reason it return only posts and pages, and no custom posts, and we have to hardcode this shit | |
| 2380 | ||
| 2381 | ||
| 2382 | return array('post' => __('Post', 'flotheme'), 'video' => __('Video', 'flotheme'), 'gallery' => __('Gallery', 'flotheme'), 'page' => __('Pages', 'flotheme'));
| |
| 2383 | } | |
| 2384 | } | |
| 2385 | ||
| 2386 | ||
| 2387 | if (!function_exists('cosmo_get_prev_next_elem')) {
| |
| 2388 | /** | |
| 2389 | * Description : this function will return the the next and prev siblings of the given element from an string | |
| 2390 | * | |
| 2391 | * params: | |
| 2392 | * $haystack - string of elements separated by comma where we are looking for our values | |
| 2393 | * $current_elem - string, the current element for which we need the siblings | |
| 2394 | * @return array that contains next and prev elem | |
| 2395 | *****/ | |
| 2396 | function cosmo_get_prev_next_elem($haystack, $current_elem) | |
| 2397 | {
| |
| 2398 | $haystack_array = explode(",", $haystack);
| |
| 2399 | ||
| 2400 | $current_key = array_search($current_elem, $haystack_array); | |
| 2401 | ||
| 2402 | if (isset($haystack_array[$current_key - 1])) {
| |
| 2403 | $siblings['previous'] = $haystack_array[$current_key - 1]; | |
| 2404 | } else {
| |
| 2405 | $siblings['previous'] = 0; | |
| 2406 | } | |
| 2407 | ||
| 2408 | if (isset($haystack_array[$current_key + 1])) {
| |
| 2409 | $siblings['next'] = $haystack_array[$current_key + 1]; | |
| 2410 | } else {
| |
| 2411 | $siblings['next'] = 0; | |
| 2412 | } | |
| 2413 | ||
| 2414 | return $siblings; | |
| 2415 | } | |
| 2416 | } | |
| 2417 | ||
| 2418 | ||
| 2419 | if (!function_exists('cosmo_get_distinct_post_terms')) {
| |
| 2420 | /* | |
| 2421 | Returns distinct taxonomies for a given post, or nothig if nothing found. | |
| 2422 | */ | |
| 2423 | function cosmo_get_distinct_post_terms($post_id, $taxonomy, $return_names = false, $filter_type = '') | |
| 2424 | {
| |
| 2425 | ||
| 2426 | $ids = array(); | |
| 2427 | $names = ''; | |
| 2428 | ||
| 2429 | $terms = wp_get_post_terms($post_id, $taxonomy); | |
| 2430 | ||
| 2431 | if (is_array($terms)) {
| |
| 2432 | foreach ($terms as $term) {
| |
| 2433 | if (!in_array($term->term_id, $ids)) {
| |
| 2434 | $ids[] = $term->term_id; | |
| 2435 | ||
| 2436 | $names .= ' ' . $term->slug . '-' . $filter_type . ' '; | |
| 2437 | } | |
| 2438 | } | |
| 2439 | } | |
| 2440 | ||
| 2441 | if ($return_names) {
| |
| 2442 | return $names; | |
| 2443 | } else {
| |
| 2444 | return $ids; | |
| 2445 | } | |
| 2446 | } | |
| 2447 | } | |
| 2448 | ||
| 2449 | if (!function_exists('cosmo_get_filters')) {
| |
| 2450 | /* | |
| 2451 | this function returns the filter by taxonomy | |
| 2452 | Params: | |
| 2453 | $term_ids - and array or term IDs | |
| 2454 | $taxonomy - for example 'category' or 'portfolio' | |
| 2455 | $filter_type - we need that to have distinct data-value, to not affect other filters | |
| 2456 | */ | |
| 2457 | function cosmo_get_filters($term_slugs, $taxonomy, $filter_type = 'thumbs', $title = '') | |
| 2458 | {
| |
| 2459 | //var_dump($term_slugs, $taxonomy);die; | |
| 2460 | $result = ''; | |
| 2461 | if (is_array($term_slugs) && sizeof($term_slugs)) {
| |
| 2462 | $result .= $title; | |
| 2463 | $result .= '<a href="#filter" data-option-value="*" class="selected">' . __('All', 'flotheme') . '</a>';
| |
| 2464 | $i = 0; | |
| 2465 | foreach ($term_slugs as $term_slug) {
| |
| 2466 | if ($term_slug != 'all') {
| |
| 2467 | $i++; | |
| 2468 | //$term = get_term( $term_id, $taxonomy ); | |
| 2469 | ||
| 2470 | $term = get_term_by('slug', $term_slug, $taxonomy);
| |
| 2471 | // var_dump($term);die; | |
| 2472 | $result .= '<a href="' . esc_url(add_query_arg('term', $term_slug) ) . '" data-filter=".' . $term->slug . '">' . $term->name . '</a>';
| |
| 2473 | } | |
| 2474 | } | |
| 2475 | } | |
| 2476 | return $result; | |
| 2477 | } | |
| 2478 | } | |
| 2479 | ||
| 2480 | ||
| 2481 | if (!function_exists('cosmoSendContact')) {
| |
| 2482 | function cosmoSendContact() | |
| 2483 | {
| |
| 2484 | if (isset($_POST['action']) && $_POST['action'] == 'cosmoSendContact') {
| |
| 2485 | $result = array(); | |
| 2486 | ||
| 2487 | $tomail = $_POST['cosmo-contact-email']; | |
| 2488 | $frommail = ''; | |
| 2489 | ||
| 2490 | if (isset($_POST['cosmo-name']) && strlen($_POST['cosmo-name'])) {
| |
| 2491 | $name = trim($_POST['cosmo-name']); | |
| 2492 | } else {
| |
| 2493 | $result['contact_name'] = '<p class="text-error">' . __('Error, name is required field. ', 'flotheme') . '</p>';
| |
| 2494 | $name = ''; | |
| 2495 | } | |
| 2496 | ||
| 2497 | if (isset($_POST['cosmo-email']) && is_email($_POST['cosmo-email'])) {
| |
| 2498 | $frommail = trim($_POST['cosmo-email']); | |
| 2499 | } else {
| |
| 2500 | ||
| 2501 | $result['contact_email'] = '<p class="text-error">' . __('Error, please enter a valid email address. ', 'flotheme') . '</p>';
| |
| 2502 | ||
| 2503 | } | |
| 2504 | ||
| 2505 | $message = ''; | |
| 2506 | if (isset($_POST['cosmo-name'])) {
| |
| 2507 | $message .= __('Contact name: ', 'flotheme') . trim($_POST['cosmo-name']) . "\n";
| |
| 2508 | } | |
| 2509 | if (isset($_POST['cosmo-email'])) {
| |
| 2510 | $message .= __('Contact email: ', 'flotheme') . trim($_POST['cosmo-email']) . "\n";
| |
| 2511 | } | |
| 2512 | if (isset($_POST['cosmo-phone'])) {
| |
| 2513 | $message .= __('Contact phone: ', 'flotheme') . trim($_POST['cosmo-phone']) . "\n\n";
| |
| 2514 | } | |
| 2515 | if (isset($_POST['cosmo-subject'])) {
| |
| 2516 | $message .= __('Subject: ', 'flotheme') . trim($_POST['cosmo-subject']) . "\n\n";
| |
| 2517 | } | |
| 2518 | ||
| 2519 | $message .= trim($_POST['cosmo-message']); | |
| 2520 | ||
| 2521 | if (is_email($tomail) && strlen($tomail) && strlen($frommail) && strlen($name) && strlen($message)) {
| |
| 2522 | ||
| 2523 | // if this option is enabled, then we will use the visitor email in the Form field | |
| 2524 | if( options::logic('blog_post', 'contact_page_from_field_source_user_email') ){
| |
| 2525 | $headers = 'From: '.trim($_POST['cosmo-name']).' <'.trim($_POST['cosmo-email']).'>'; | |
| 2526 | }else{
| |
| 2527 | $headers = ''; | |
| 2528 | } | |
| 2529 | ||
| 2530 | $subject = __('New email from', 'flotheme') . ' ' . get_bloginfo('name') . '.' . __(' Sent via contact form.', 'flotheme');
| |
| 2531 | wp_mail($tomail, $subject, $message, $headers); | |
| 2532 | ||
| 2533 | if (isset($_POST['thx_msg']) && strlen(trim($_POST['thx_msg']))) {
| |
| 2534 | $thx_msg = urldecode($_POST['thx_msg']); | |
| 2535 | } else {
| |
| 2536 | $thx_msg = __('Email was sent successfully ', 'flotheme');
| |
| 2537 | } | |
| 2538 | ||
| 2539 | $result['message'] = '<span class="text-success" >' . $thx_msg . '</span>'; | |
| 2540 | ||
| 2541 | } | |
| 2542 | ||
| 2543 | echo json_encode($result); | |
| 2544 | } | |
| 2545 | ||
| 2546 | ||
| 2547 | exit(); | |
| 2548 | } | |
| 2549 | } | |
| 2550 | ||
| 2551 | if (!function_exists('flo_get_slideshow')) {
| |
| 2552 | function flo_get_slideshow($slideshow_id) | |
| 2553 | {
| |
| 2554 | global $post; | |
| 2555 | if(strpos(get_page_template_slug( $post->ID), 'template-contact-form') == false && | |
| 2556 | strpos(get_page_template_slug( $post->ID), 'template-gallery') == false ){
| |
| 2557 | global $slideshow; | |
| 2558 | $slideshow = meta::get_meta($slideshow_id, '_floslideshow'); | |
| 2559 | ||
| 2560 | if (!(isset($slideshow) && is_array($slideshow) && count($slideshow))) {
| |
| 2561 | return; | |
| 2562 | } | |
| 2563 | ||
| 2564 | if (!empty($slideshow) && is_array($slideshow) ) {
| |
| 2565 | ||
| 2566 | $page_slyder_info = flo_get_page_slyder_info(); | |
| 2567 | ||
| 2568 | if(isset($page_slyder_info['slideshow_type']) && $page_slyder_info['slideshow_type'] != 'content_width' ){
| |
| 2569 | $slider_type = 'full_width'; // will use full-width.php slidehow template | |
| 2570 | }else{
| |
| 2571 | $slider_type = 'content_width'; | |
| 2572 | } | |
| 2573 | ||
| 2574 | // use Royal slider | |
| 2575 | ||
| 2576 | get_template_part( '/parts/slideshow/'.$slider_type); | |
| 2577 | ||
| 2578 | ||
| 2579 | } | |
| 2580 | } | |
| 2581 | ||
| 2582 | } | |
| 2583 | } | |
| 2584 | ||
| 2585 | /** | |
| 2586 | * Reset options | |
| 2587 | * @return void | |
| 2588 | */ | |
| 2589 | if (!function_exists('cResetOptions')) {
| |
| 2590 | function cResetOptions() | |
| 2591 | {
| |
| 2592 | ||
| 2593 | $theme_options = options::$menu['flothemes']; | |
| 2594 | if (sizeof($theme_options)) {
| |
| 2595 | foreach ($theme_options as $key => $value) {
| |
| 2596 | delete_option($key); | |
| 2597 | } | |
| 2598 | } | |
| 2599 | } | |
| 2600 | } | |
| 2601 | ||
| 2602 | /** | |
| 2603 | * get category taxonomy | |
| 2604 | * @param int - post_id | |
| 2605 | * @return string - category taxony slug for the passed post id | |
| 2606 | */ | |
| 2607 | if (!function_exists('flo_get_categ_tax')) {
| |
| 2608 | function flo_get_categ_tax($post_id) | |
| 2609 | {
| |
| 2610 | ||
| 2611 | $current_post_type = get_post_type($post_id); | |
| 2612 | ||
| 2613 | // category taxonomy array for each post type | |
| 2614 | $categ_taxonomies = array('post' => 'category',
| |
| 2615 | 'video' => 'video-category', | |
| 2616 | 'gallery' => 'gallery-category' | |
| 2617 | ); | |
| 2618 | if (isset($categ_taxonomies[$current_post_type])) {
| |
| 2619 | return $categ_taxonomies[$current_post_type]; | |
| 2620 | } else {
| |
| 2621 | return ''; | |
| 2622 | } | |
| 2623 | ||
| 2624 | } | |
| 2625 | } | |
| 2626 | ||
| 2627 | ||
| 2628 | if (!function_exists('flo_video_embed')) {
| |
| 2629 | function flo_video_embed() | |
| 2630 | { //echo 'qweqweqwe';
| |
| 2631 | if (isset($_POST['post_id']) && is_numeric($_POST['post_id'])) { // if post ID is passed vide URL
| |
| 2632 | $embed_meta = get_post_meta($_POST['post_id'], 'cosmoembed', true); | |
| 2633 | ||
| 2634 | $result = array(); | |
| 2635 | if (cosmo_isValidURL($embed_meta['url'])) {
| |
| 2636 | // for URL | |
| 2637 | global $wp_embed; | |
| 2638 | $wp_embed->post_ID = $_POST['post_id']; // use this trick to make the video work via ajax :) | |
| 2639 | ||
| 2640 | $result['video'] = $wp_embed->run_shortcode('[embed autoplay="1" ]' . trim($embed_meta['url']) . '[/embed]');
| |
| 2641 | } else {
| |
| 2642 | // for embeds | |
| 2643 | $result['video'] = $embed_meta['url']; | |
| 2644 | } | |
| 2645 | ||
| 2646 | echo json_encode($result); | |
| 2647 | } | |
| 2648 | exit(); | |
| 2649 | } | |
| 2650 | ||
| 2651 | } | |
| 2652 | ||
| 2653 | if (!function_exists('flo_post_nav')) :
| |
| 2654 | /** | |
| 2655 | * Displays navigation to next/previous post when applicable. | |
| 2656 | * | |
| 2657 | * | |
| 2658 | * @return void | |
| 2659 | */ | |
| 2660 | function flo_post_nav($middle_page_id = 0) | |
| 2661 | {
| |
| 2662 | global $post; | |
| 2663 | $previous = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', true); | |
| 2664 | $next = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', false); | |
| 2665 | $gallery_next_label = options::get_value('labels', 'next_gallery_label');
| |
| 2666 | $gallery_prev_label = options::get_value('labels', 'prev_gallery_label');
| |
| 2667 | $post_next_label = options::get_value('labels', 'next_post_label');
| |
| 2668 | $post_prev_label = options::get_value('labels', 'prev_post_label');
| |
| 2669 | $video_next_label = options::get_value('labels', 'next_video_label');
| |
| 2670 | $video_prev_label = options::get_value('labels', 'prev_video_label');
| |
| 2671 | if ($previous) {
| |
| 2672 | if ($post->post_type == 'gallery') {
| |
| 2673 | previous_post_link('%link', _x('<span class="the-text link prev-gallery"><span class="link-separator">/ </span>' . $gallery_prev_label . '</span>', 'Previous post link', 'flotheme'));
| |
| 2674 | } elseif ($post->post_type == 'video') {
| |
| 2675 | previous_post_link('%link', _x('<span class="the-text link next">' . $video_prev_label . '</span>', 'Previous post link', 'flotheme'));
| |
| 2676 | } else {
| |
| 2677 | previous_post_link('%link', _x('<span class="the-text link next">' . $post_prev_label . '</span>', 'Previous post link', 'flotheme'));
| |
| 2678 | } | |
| 2679 | } else {
| |
| 2680 | echo '<a href="#" rel="prev"><span></span></a>'; | |
| 2681 | } | |
| 2682 | if ($post->post_type == 'gallery') {
| |
| 2683 | next_post_link('%link', _x('<span class="the-text link next-gallery"><span class="link-separator">/ </span>' . $gallery_next_label . '</span> ', 'Next post link', 'flotheme'));
| |
| 2684 | } elseif ($post->post_type == 'video') {
| |
| 2685 | next_post_link('%link', _x('<span class="the-text link prev">' . $video_next_label . '</span> ', 'Next post link', 'flotheme'));
| |
| 2686 | } else {
| |
| 2687 | next_post_link('%link', _x('<span class="the-text link prev">' . $post_next_label . '</span> ', 'Next post link', 'flotheme'));
| |
| 2688 | } | |
| 2689 | ?> | |
| 2690 | ||
| 2691 | <?php | |
| 2692 | } | |
| 2693 | endif; | |
| 2694 | /** | |
| 2695 | * // returns the gallery type assigned for a given gallery, or the default setting if the given post does not have that setting. | |
| 2696 | */ | |
| 2697 | if (!function_exists('get_posts_gallery_type')) {
| |
| 2698 | function get_posts_gallery_type($post_id) | |
| 2699 | {
| |
| 2700 | $gallerytype = meta::get_meta($post_id, 'gallerytype'); | |
| 2701 | ||
| 2702 | if (isset($gallerytype['value']) && strlen($gallerytype['value'])) {
| |
| 2703 | return $gallerytype['value']; | |
| 2704 | } else {
| |
| 2705 | return options::get_value('content_settings', 'single_gallery_layout');
| |
| 2706 | } | |
| 2707 | ||
| 2708 | } | |
| 2709 | } | |
| 2710 | ||
| 2711 | /** | |
| 2712 | * Include gallery manager | |
| 2713 | */ | |
| 2714 | include_once('attached_images_manager.php');
| |
| 2715 | ||
| 2716 | // slideshow manager | |
| 2717 | include_once('slideshow_attached_images_manager.php');
| |
| 2718 | ||
| 2719 | /*----------------------------------------------------------------------------------------------------------------------------------------*/ | |
| 2720 | ||
| 2721 | /* related posts by herarchical taxonomy */ | |
| 2722 | /* get tax slugs and number of similar posts */ | |
| 2723 | function similar_query($post_id, $taxonomy, $posts_per_page = 4) | |
| 2724 | {
| |
| 2725 | ||
| 2726 | $the_post_type = get_post_type($post_id); | |
| 2727 | if ('video' == $the_post_type) {
| |
| 2728 | if ($taxonomy == 'post_tag') {
| |
| 2729 | $taxonomy = 'tag'; | |
| 2730 | } | |
| 2731 | $taxonomy = 'video-' . $taxonomy; | |
| 2732 | } | |
| 2733 | ||
| 2734 | $topics = wp_get_post_terms($post_id, $taxonomy); | |
| 2735 | ||
| 2736 | $terms = array(); | |
| 2737 | if (!empty($topics)) {
| |
| 2738 | foreach ($topics as $topic) {
| |
| 2739 | $term = get_term($topic->term_id, $taxonomy); | |
| 2740 | if (isset($term->slug)) {
| |
| 2741 | array_push($terms, $term->slug); | |
| 2742 | } | |
| 2743 | ||
| 2744 | } | |
| 2745 | } | |
| 2746 | ||
| 2747 | if (!empty($terms)) {
| |
| 2748 | $query = new WP_Query(array( | |
| 2749 | 'post_type' => $the_post_type, | |
| 2750 | 'post__not_in' => array($post_id), | |
| 2751 | 'posts_per_page' => $posts_per_page, | |
| 2752 | 'orderby' => 'rand', | |
| 2753 | 'ignore_sticky_posts' => 1, | |
| 2754 | 'tax_query' => array( | |
| 2755 | array( | |
| 2756 | 'taxonomy' => $taxonomy, | |
| 2757 | 'field' => 'slug', | |
| 2758 | 'terms' => $terms, | |
| 2759 | ) | |
| 2760 | ) | |
| 2761 | )); | |
| 2762 | } else {
| |
| 2763 | $query = array(); | |
| 2764 | } | |
| 2765 | ||
| 2766 | ||
| 2767 | return $query; | |
| 2768 | } | |
| 2769 | ||
| 2770 | if (!function_exists('flo_set_transparent_header')) {
| |
| 2771 | function flo_set_transparent_header() | |
| 2772 | {
| |
| 2773 | //deb::e(is_page()); | |
| 2774 | if ((is_page() || (is_single() && get_post_type() == 'post')) && !wp_is_mobile()) { //only for pages
| |
| 2775 | global $post; | |
| 2776 | ||
| 2777 | $sl_settings = meta::get_meta($post->ID, 'slideshowSettings'); | |
| 2778 | ||
| 2779 | if ((isset($sl_settings['slideshow_select']) && is_numeric($sl_settings['slideshow_select']) && $sl_settings['slideshow_select'] != '0') || | |
| 2780 | (is_single() && has_post_thumbnail($post->ID) && options::logic('blog_post', 'show_single_featured') && !post_password_required())
| |
| 2781 | ) {
| |
| 2782 | ||
| 2783 | ||
| 2784 | ?> | |
| 2785 | <?php | |
| 2786 | ||
| 2787 | } | |
| 2788 | ||
| 2789 | } | |
| 2790 | } | |
| 2791 | } | |
| 2792 | ||
| 2793 | /** | |
| 2794 | * gallery shortcode using massonry | |
| 2795 | * | |
| 2796 | * @param string $output | |
| 2797 | * @param array $attr | |
| 2798 | * | |
| 2799 | * @return string | |
| 2800 | */ | |
| 2801 | function flo_post_gallery($output, $attr) | |
| 2802 | {
| |
| 2803 | global $post, $wp_locale; | |
| 2804 | ||
| 2805 | static $instance = 0; | |
| 2806 | $instance++; | |
| 2807 | ||
| 2808 | if (isset($attr['orderby'])) {
| |
| 2809 | $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); | |
| 2810 | if (!$attr['orderby']) | |
| 2811 | unset($attr['orderby']); | |
| 2812 | } | |
| 2813 | ||
| 2814 | $size = 'large'; | |
| 2815 | ||
| 2816 | extract(shortcode_atts(array( | |
| 2817 | 'order' => 'ASC', | |
| 2818 | 'orderby' => 'menu_order ID', | |
| 2819 | 'id' => $post->ID, | |
| 2820 | 'itemtag' => 'dl', | |
| 2821 | 'icontag' => 'dt', | |
| 2822 | 'captiontag' => 'dd', | |
| 2823 | 'columns' => 3, | |
| 2824 | 'size' => $size, | |
| 2825 | 'include' => '', | |
| 2826 | 'exclude' => '' | |
| 2827 | ), $attr)); | |
| 2828 | ||
| 2829 | $id = intval($id); | |
| 2830 | if ('RAND' == $order)
| |
| 2831 | $orderby = 'none'; | |
| 2832 | ||
| 2833 | if (!empty($include)) {
| |
| 2834 | $include = preg_replace('/[^0-9,]+/', '', $include);
| |
| 2835 | $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
| |
| 2836 | ||
| 2837 | $attachments = array(); | |
| 2838 | foreach ($_attachments as $key => $val) {
| |
| 2839 | $attachments[$val->ID] = $_attachments[$key]; | |
| 2840 | } | |
| 2841 | } elseif (!empty($exclude)) {
| |
| 2842 | $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
| |
| 2843 | $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
| |
| 2844 | } else {
| |
| 2845 | $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
| |
| 2846 | } | |
| 2847 | ||
| 2848 | if (empty($attachments)) | |
| 2849 | return ''; | |
| 2850 | ||
| 2851 | if (is_feed()) {
| |
| 2852 | $output = "\n"; | |
| 2853 | foreach ($attachments as $att_id => $attachment) | |
| 2854 | $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; | |
| 2855 | return $output; | |
| 2856 | } | |
| 2857 | ||
| 2858 | // check if the massonry is enabled | |
| 2859 | if(options::logic( 'content_settings' , 'use_massonry_gallery_shortcode' )){
| |
| 2860 | $shcode_massonry_class = 'js-masonry'; | |
| 2861 | }else{
| |
| 2862 | $shcode_massonry_class = ''; | |
| 2863 | } | |
| 2864 | ||
| 2865 | // if there is only 1 column, then the massonry is disabled | |
| 2866 | if($columns == 1){
| |
| 2867 | $shcode_massonry_class = 1; | |
| 2868 | } | |
| 2869 | ||
| 2870 | ||
| 2871 | $output = '<section class="flo-gallery-shortcode grid-view grid-masonry gallery-'.$columns.'-columns"><div class="gallery-shortcode-wrap '.$shcode_massonry_class.'">'; | |
| 2872 | ||
| 2873 | ||
| 2874 | $i = 0; | |
| 2875 | $rand_id = mt_rand(1, 1000); | |
| 2876 | ||
| 2877 | $block_width = ' ' . cosmo_columns_arabic_to_chars($columns) . ' '; | |
| 2878 | ||
| 2879 | foreach ($attachments as $id => $attachment) {
| |
| 2880 | $image_attributes = wp_get_attachment_image_src($id, 'full'); | |
| 2881 | ||
| 2882 | if (isset($attachment->post_excerpt) && strlen($attachment->post_excerpt)) {
| |
| 2883 | $image_caption = $attachment->post_excerpt; | |
| 2884 | } else {
| |
| 2885 | $image_caption = ''; | |
| 2886 | } | |
| 2887 | ||
| 2888 | if (isset($attachment->post_content) && strlen($attachment->post_content)) {
| |
| 2889 | $image_description = $attachment->post_content; | |
| 2890 | } else {
| |
| 2891 | $image_description = ''; | |
| 2892 | } | |
| 2893 | ||
| 2894 | $src = wp_get_attachment_image_src($id, 'full'); // get full attachment source | |
| 2895 | if (isset($src[0])) {
| |
| 2896 | $src = $src[0]; | |
| 2897 | } else {
| |
| 2898 | $src = ''; | |
| 2899 | } | |
| 2900 | ||
| 2901 | if($columns == 1){
| |
| 2902 | // if the user is using 1 columns, we will crop the images differently | |
| 2903 | options::get_value( 'layout' , 'site_width' ); | |
| 2904 | if(!is_numeric($site_width)){
| |
| 2905 | $site_width = 1130; | |
| 2906 | } | |
| 2907 | ||
| 2908 | $img_url = aq_resize($src, $site_width, 9999, $crop = false, $single = true); //resize img , height 400px | |
| 2909 | }else{
| |
| 2910 | $img_url = aq_resize($src, 9999, 900, $crop = false, $single = true); //resize img , height 400px | |
| 2911 | } | |
| 2912 | ||
| 2913 | ||
| 2914 | // if for some reason it is not possible to resize the image, we will use the original image | |
| 2915 | if($img_url == ''){
| |
| 2916 | $img_url = $src; | |
| 2917 | } | |
| 2918 | ||
| 2919 | //$link = '<a href="'.$image_attributes[0].'" data-fancybox-group="prettyPhoto['.$rand_id.']" title="'.$image_caption . $image_description.'" >'.wp_get_attachment_image($id, $size, false).'</a>'; | |
| 2920 | $link = '<div class=" post-preview gallery-shortcode flo-' . $columns . '-columns" ><a href="' . $image_attributes[0] . '" class="no-lazy" data-fancybox-group="prettyPhoto[' . $rand_id . ']" title="' . esc_attr($image_caption) .' '. esc_attr($image_description) . '" ><img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="' . $img_url . '" alt="' . $attachment->post_title . '" /></a></div>'; | |
| 2921 | $output .= $link; | |
| 2922 | ||
| 2923 | } | |
| 2924 | ||
| 2925 | $output .= "</div></section>\n"; | |
| 2926 | ||
| 2927 | //enable massonry | |
| 2928 | wp_localize_script('functions', 'enable_massonry', '1');
| |
| 2929 | ||
| 2930 | /* include jquery.fancybox.pack*/ | |
| 2931 | wp_register_style('fancybox', get_template_directory_uri() . '/js/fancybox/jquery.fancybox.css');
| |
| 2932 | wp_enqueue_style('fancybox');
| |
| 2933 | ||
| 2934 | wp_enqueue_script('apps', get_template_directory_uri() . '/js/fancybox/jquery.fancybox.pack.js', array( 'jquery' ),'',true);
| |
| 2935 | ||
| 2936 | return $output; | |
| 2937 | } | |
| 2938 | ||
| 2939 | /** | |
| 2940 | * render the comments | |
| 2941 | */ | |
| 2942 | function flo_comment($comment, $args, $depth) | |
| 2943 | {
| |
| 2944 | ||
| 2945 | $GLOBALS['comment'] = $comment; | |
| 2946 | switch ($comment->comment_type) {
| |
| 2947 | case '' : | |
| 2948 | {
| |
| 2949 | ?> | |
| 2950 | <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> | |
| 2951 | <article id="comment-<?php comment_ID(); ?>" class="comment-body"> | |
| 2952 | <div class="comment-meta"> | |
| 2953 | <h2 class="comment-author-name"><?php echo get_comment_author_link($comment->comment_ID); ?> <span><?php echo _e('said', 'flotheme') ?>:</span></h2>
| |
| 2954 | <!-- <span class="comment-period"><?php _e('on', 'flotheme'); ?> <?php printf(__('%1$s %2$s', 'flotheme'), get_comment_date(), get_comment_time()); ?></span> -->
| |
| 2955 | <div class="reply-wrap"> | |
| 2956 | <span class="gray reply fr"><?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?></span>
| |
| 2957 | </div> | |
| 2958 | </div> | |
| 2959 | <div class="comment-content-wrap"> | |
| 2960 | <div class="comment-content"> | |
| 2961 | <p> | |
| 2962 | <?php | |
| 2963 | $order = array("\r\n", "\n", "\r");
| |
| 2964 | $replace = '<br />'; | |
| 2965 | echo str_replace($order, $replace, get_comment_text()); | |
| 2966 | ?> | |
| 2967 | </p> | |
| 2968 | </div> | |
| 2969 | <!-- end .comment-content --> | |
| 2970 | </div> | |
| 2971 | </article> | |
| 2972 | <?php | |
| 2973 | break; | |
| 2974 | } | |
| 2975 | case 'pingback' : | |
| 2976 | {
| |
| 2977 | } | |
| 2978 | case 'trackback' : | |
| 2979 | {
| |
| 2980 | ?> | |
| 2981 | <li class="pingback"> | |
| 2982 | <p> | |
| 2983 | <?php | |
| 2984 | _e('Pingback', 'flotheme'); ?> : <?php comment_author_link(); ?><?php edit_comment_link('(' . __('Edit', 'flotheme') . ')', ' ');
| |
| 2985 | ?> | |
| 2986 | </p> | |
| 2987 | <?php | |
| 2988 | break; | |
| 2989 | } | |
| 2990 | } | |
| 2991 | } | |
| 2992 | ||
| 2993 | ||
| 2994 | /* imports dummy content and settings */ | |
| 2995 | function importDummyData() | |
| 2996 | {
| |
| 2997 | ||
| 2998 | ||
| 2999 | //$import_archive = get_theme_root(PLAYGROUND_TEMPLATE) . '/' . PLAYGROUND_TEMPLATE . '/import-archives/' . implode('#', array($theme_slug, $skin_slug, $homepage_slug)) . '.zip';
| |
| 3000 | ||
| 3001 | require_once get_template_directory() . '/lib/demo_content/flo-importer/wordpress-importer.php'; | |
| 3002 | ||
| 3003 | //$tmp_dir = dirname($import_archive) . '/' . uniqid() . md5(time()); | |
| 3004 | if (isset($_POST['folder'])) {
| |
| 3005 | $import_dir = $_POST['folder']; | |
| 3006 | } else {
| |
| 3007 | $import_dir = 'export'; | |
| 3008 | } | |
| 3009 | $tmp_dir = get_template_directory() . '/lib/demo_content/' . $import_dir . '/'; | |
| 3010 | ||
| 3011 | if (class_exists('Flo_Import_Dummy_Data')) {
| |
| 3012 | ||
| 3013 | $flo_importer = new Flo_Import_Dummy_Data(); | |
| 3014 | ob_start(); | |
| 3015 | $result = $flo_importer->install_programatically($tmp_dir); | |
| 3016 | $buffer = ob_get_clean(); | |
| 3017 | if ($result && stripos($buffer, '<p>All done.') !== false) {
| |
| 3018 | die(json_encode(array('message' => 'All good!', 'code' => 1)));
| |
| 3019 | } else {
| |
| 3020 | die(json_encode(array('message' => 'Something went wrong. Please contact administrator', 'code' => -1)));
| |
| 3021 | } | |
| 3022 | } else {
| |
| 3023 | die(json_encode(array('message' => 'Missing importer class. Please contact administrator.', 'code' => -1)));
| |
| 3024 | } | |
| 3025 | ||
| 3026 | exit(); | |
| 3027 | } | |
| 3028 | ||
| 3029 | ||
| 3030 | if (!function_exists('flo_wpforce_featured')) {
| |
| 3031 | /* if a post does not have featured image, then we set the first attached image as feat img */ | |
| 3032 | function flo_wpforce_featured() | |
| 3033 | {
| |
| 3034 | if (options::logic('blog_post', 'auto_feat_img')) {
| |
| 3035 | global $post; | |
| 3036 | ||
| 3037 | $post_types_to_work_with = array('post', 'gallery'); // add more posts here if you want.
| |
| 3038 | ||
| 3039 | if (isset($post->ID)) {
| |
| 3040 | $the_post_format = get_post_type($post->ID); | |
| 3041 | } else {
| |
| 3042 | $the_post_format = 'unknown'; | |
| 3043 | } | |
| 3044 | ||
| 3045 | ||
| 3046 | if (in_array($the_post_format, $post_types_to_work_with)) {
| |
| 3047 | $already_has_thumb = has_post_thumbnail($post->ID); | |
| 3048 | if (!$already_has_thumb) {
| |
| 3049 | $attached_image = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1");
| |
| 3050 | if ($attached_image) {
| |
| 3051 | foreach ($attached_image as $attachment_id => $attachment) {
| |
| 3052 | set_post_thumbnail($post->ID, $attachment_id); | |
| 3053 | } | |
| 3054 | } | |
| 3055 | } | |
| 3056 | } | |
| 3057 | ||
| 3058 | } | |
| 3059 | ||
| 3060 | } //end function | |
| 3061 | } | |
| 3062 | ||
| 3063 | add_action('the_post', 'flo_wpforce_featured');
| |
| 3064 | add_action('save_post', 'flo_wpforce_featured');
| |
| 3065 | add_action('draft_to_publish', 'flo_wpforce_featured');
| |
| 3066 | add_action('new_to_publish', 'flo_wpforce_featured');
| |
| 3067 | add_action('pending_to_publish', 'flo_wpforce_featured');
| |
| 3068 | add_action('future_to_publish', 'flo_wpforce_featured');
| |
| 3069 | ||
| 3070 | ||
| 3071 | function flo_dashboard_documentation() | |
| 3072 | {
| |
| 3073 | return array("<li class='flo-docs' ><a href='"._FLO_DOCS_."' target='_blank' ><img src='" . get_template_directory_uri() . "/images/documentation_img.jpg' /></a></li>");
| |
| 3074 | } | |
| 3075 | ||
| 3076 | add_filter('dashboard_glance_items', 'flo_dashboard_documentation');
| |
| 3077 | ||
| 3078 | ||
| 3079 | /** | |
| 3080 | * check if a link exists and don’t return a 404 message | |
| 3081 | * | |
| 3082 | * @params: string - the URL that must be checked | |
| 3083 | * @return boolean | |
| 3084 | */ | |
| 3085 | if (!function_exists('flo_maybe_image_exists')) {
| |
| 3086 | function flo_maybe_image_exists($url) | |
| 3087 | {
| |
| 3088 | // Let's see if we have a cached version of HTTP request | |
| 3089 | $cached_request = get_transient(md5($url)); | |
| 3090 | ||
| 3091 | ||
| 3092 | if (false === $cached_request) {
| |
| 3093 | $response = wp_remote_get($url); | |
| 3094 | ||
| 3095 | // save to transieant to not make requests every time | |
| 3096 | set_transient(md5($url), $response, 60 * 60 * 24 * 30); /* save transient for 30 days */ | |
| 3097 | } else {
| |
| 3098 | $response = $cached_request; | |
| 3099 | ||
| 3100 | } | |
| 3101 | ||
| 3102 | ||
| 3103 | if (is_wp_error($response)) | |
| 3104 | //request can't performed | |
| 3105 | return false; | |
| 3106 | if (wp_remote_retrieve_response_code($response) == '404') {
| |
| 3107 | //request succeed and link not found | |
| 3108 | return false; | |
| 3109 | } | |
| 3110 | ||
| 3111 | //request succeed and link exist | |
| 3112 | return true; | |
| 3113 | } | |
| 3114 | } | |
| 3115 | ||
| 3116 | ||
| 3117 | // add action for footer credits | |
| 3118 | // only if it is not overwritten by a plugin | |
| 3119 | if (!has_action('flo_footer_credits')) {
| |
| 3120 | add_action('flo_footer_credits', 'flo_get_footer_credits', 10);
| |
| 3121 | } | |
| 3122 | ||
| 3123 | /** | |
| 3124 | * outputs the footer credits | |
| 3125 | * | |
| 3126 | * @params: none | |
| 3127 | * @return --- | |
| 3128 | */ | |
| 3129 | if (!function_exists('flo_get_footer_credits')) {
| |
| 3130 | function flo_get_footer_credits() | |
| 3131 | {
| |
| 3132 | echo '<br/><a href="http://flothemes.com/"><img src="'.get_template_directory_uri().'/favicon.ico" /></a>'; | |
| 3133 | } | |
| 3134 | ||
| 3135 | } | |
| 3136 | ||
| 3137 | /** | |
| 3138 | * check if a given page has sidebar | |
| 3139 | * | |
| 3140 | * @params: none | |
| 3141 | * @return --- bool | |
| 3142 | */ | |
| 3143 | if (!function_exists('flo_has_sidebar')) {
| |
| 3144 | ||
| 3145 | function flo_has_sidebar(){
| |
| 3146 | $has_sidebar = false; | |
| 3147 | ||
| 3148 | global $post; | |
| 3149 | ||
| 3150 | if(is_singular()){
| |
| 3151 | ||
| 3152 | ||
| 3153 | $layout = meta::get_meta($post -> ID, 'layout'); | |
| 3154 | ||
| 3155 | $post_type = get_post_type($post -> ID); | |
| 3156 | ||
| 3157 | ||
| 3158 | switch ($post_type) {
| |
| 3159 | case 'page': | |
| 3160 | ||
| 3161 | if(isset($layout['type']) ){
| |
| 3162 | if( 'left' == $layout['type'] || 'right' == $layout['type'] ){
| |
| 3163 | $has_sidebar = true; | |
| 3164 | } | |
| 3165 | }else{
| |
| 3166 | $default_page_layout = options::get_value('layout', 'page');
| |
| 3167 | if('full' != $default_page_layout){
| |
| 3168 | $has_sidebar = true; | |
| 3169 | } | |
| 3170 | } | |
| 3171 | ||
| 3172 | break; | |
| 3173 | ||
| 3174 | case 'post': | |
| 3175 | if(isset($layout['type']) ){
| |
| 3176 | if( 'left' == $layout['type'] || 'right' == $layout['type'] ){
| |
| 3177 | $has_sidebar = true; | |
| 3178 | } | |
| 3179 | }else{
| |
| 3180 | $default_page_layout = options::get_value('layout', 'single');
| |
| 3181 | if('full' != $default_page_layout){
| |
| 3182 | $has_sidebar = true; | |
| 3183 | } | |
| 3184 | } | |
| 3185 | break; | |
| 3186 | ||
| 3187 | default: | |
| 3188 | ||
| 3189 | break; | |
| 3190 | } | |
| 3191 | ||
| 3192 | }else{
| |
| 3193 | ||
| 3194 | if (is_search()) {
| |
| 3195 | $the_layout = options::get_value('layout', 'search');
| |
| 3196 | if('full' != $the_layout){
| |
| 3197 | $has_sidebar = true; | |
| 3198 | } | |
| 3199 | } elseif (is_tag() || is_tax('video-tag')|| is_tax('gallery-tag')) {
| |
| 3200 | $the_layout = options::get_value('layout', 'tag');
| |
| 3201 | if('full' != $the_layout){
| |
| 3202 | $has_sidebar = true; | |
| 3203 | } | |
| 3204 | ||
| 3205 | } elseif (is_category()|| is_tax('video-category')|| is_tax('gallery-category') ) {
| |
| 3206 | $the_layout = options::get_value('layout', 'category');
| |
| 3207 | if('full' != $the_layout){
| |
| 3208 | $has_sidebar = true; | |
| 3209 | } | |
| 3210 | ||
| 3211 | } elseif (is_author()) {
| |
| 3212 | $the_layout = options::get_value('layout', 'author');
| |
| 3213 | if('full' != $the_layout){
| |
| 3214 | $has_sidebar = true; | |
| 3215 | } | |
| 3216 | ||
| 3217 | } elseif (is_home()) { /*blog page*/
| |
| 3218 | $the_layout = options::get_value('layout', 'blog_page');
| |
| 3219 | if('full' != $the_layout){
| |
| 3220 | $has_sidebar = true; | |
| 3221 | } | |
| 3222 | ||
| 3223 | } elseif (is_archive()) {
| |
| 3224 | $the_layout = options::get_value('layout', 'archive');
| |
| 3225 | if('full' != $the_layout){
| |
| 3226 | $has_sidebar = true; | |
| 3227 | } | |
| 3228 | ||
| 3229 | } elseif (is_404()) {
| |
| 3230 | $the_layout = options::get_value('layout', '404');
| |
| 3231 | if('full' != $the_layout){
| |
| 3232 | $has_sidebar = true; | |
| 3233 | } | |
| 3234 | ||
| 3235 | } | |
| 3236 | } | |
| 3237 | ||
| 3238 | return $has_sidebar; | |
| 3239 | } | |
| 3240 | ||
| 3241 | ||
| 3242 | } | |
| 3243 | ||
| 3244 | ||
| 3245 | ||
| 3246 | /*Upload image for title decoration */ | |
| 3247 | function true_include_myuploadscript() {
| |
| 3248 | // у вас в админке уже должен быть подключен jQuery, если нет - раскомментируйте следующую строку: | |
| 3249 | // wp_enqueue_script('jquery');
| |
| 3250 | // дальше у нас идут скрипты и стили загрузчика изображений WordPress | |
| 3251 | if ( ! did_action( 'wp_enqueue_media' ) ) {
| |
| 3252 | wp_enqueue_media(); | |
| 3253 | } | |
| 3254 | // само собой - меняем admin.js на название своего файла | |
| 3255 | wp_enqueue_script( 'myuploadscript', get_template_directory_uri() . '/js/admin.js', array('jquery'), null, false );
| |
| 3256 | } | |
| 3257 | ||
| 3258 | add_action( 'admin_enqueue_scripts', 'true_include_myuploadscript' ); | |
| 3259 | ||
| 3260 | function true_image_uploader_field( $name, $value = '', $w = 115, $h = 90) {
| |
| 3261 | $default = get_template_directory_uri() . '/images/no_img.png'; | |
| 3262 | if( $value ) {
| |
| 3263 | $image_attributes = wp_get_attachment_image_src( $value, array($w, $h) ); | |
| 3264 | $src = $image_attributes[0]; | |
| 3265 | } else {
| |
| 3266 | $src = $default; | |
| 3267 | } | |
| 3268 | ||
| 3269 | echo ' | |
| 3270 | <div> | |
| 3271 | <img data-src="' . $default . '" src="' . $src . '" width="' . $w . 'px" height="' . $h . 'px" /> | |
| 3272 | <div> | |
| 3273 | <input type="hidden" name="' . $name . '" id="' . $name . '" value="' . $value . '" /> | |
| 3274 | <button type="submit" class="upload_image_button button">Upload</button> | |
| 3275 | <button type="submit" class="remove_image_button button">×</button> | |
| 3276 | </div> | |
| 3277 | </div> | |
| 3278 | '; | |
| 3279 | } | |
| 3280 | ||
| 3281 | /* | |
| 3282 | * Добавляем метабокс | |
| 3283 | */ | |
| 3284 | function true_meta_boxes_u() {
| |
| 3285 | $post_types = array('post', 'page');
| |
| 3286 | add_meta_box('truediv', 'Title decoration image', 'true_print_box_u', 'page', 'side');
| |
| 3287 | add_meta_box('truediv', 'Title decoration image', 'true_print_box_u', 'post', 'side');
| |
| 3288 | add_meta_box('truediv', 'Title decoration image', 'true_print_box_u', 'video', 'side');
| |
| 3289 | add_meta_box('truediv', 'Title decoration image', 'true_print_box_u', 'gallery', 'side');
| |
| 3290 | } | |
| 3291 | ||
| 3292 | add_action( 'admin_menu', 'true_meta_boxes_u' ); | |
| 3293 | ||
| 3294 | /* | |
| 3295 | * Заполняем метабокс | |
| 3296 | */ | |
| 3297 | function true_print_box_u($post) {
| |
| 3298 | if( function_exists( 'true_image_uploader_field' ) ) {
| |
| 3299 | true_image_uploader_field( 'uploader_custom', get_post_meta($post->ID, 'uploader_custom',true) ); | |
| 3300 | } | |
| 3301 | } | |
| 3302 | ||
| 3303 | /* | |
| 3304 | * Сохраняем данные произвольного поля | |
| 3305 | */ | |
| 3306 | function true_save_box_data_u( $post_id ) {
| |
| 3307 | if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
| |
| 3308 | return $post_id; | |
| 3309 | if(isset($_POST['uploader_custom'])){
| |
| 3310 | update_post_meta( $post_id, 'uploader_custom', $_POST['uploader_custom']); | |
| 3311 | } | |
| 3312 | return $post_id; | |
| 3313 | } | |
| 3314 | ||
| 3315 | add_action('save_post', 'true_save_box_data_u');
| |
| 3316 | ||
| 3317 | function true_add_options_page_u() {
| |
| 3318 | if ( isset( $_GET['page'] ) == 'uplsettings' ) {
| |
| 3319 | if ( 'save' == isset( $_REQUEST['action'] ) ) {
| |
| 3320 | if(isset($_REQUEST[ 'uploader_custom' ])){
| |
| 3321 | update_option('uploader_custom', $_REQUEST[ 'uploader_custom' ]);
| |
| 3322 | header("Location: ". site_url() ."/wp-admin/options-general.php?page=uplsettings&saved=true");
| |
| 3323 | die; | |
| 3324 | } | |
| 3325 | } | |
| 3326 | } | |
| 3327 | // add_submenu_page('options-general.php','Дополнительные настройки','Настройки','edit_posts', 'uplsettings', 'true_print_options_u');
| |
| 3328 | } | |
| 3329 | ||
| 3330 | function true_print_options_u() {
| |
| 3331 | if ( isset( $_REQUEST['saved'] ) ){
| |
| 3332 | echo '<div class="updated"><p>Saved.</p></div>'; | |
| 3333 | } | |
| 3334 | ?><div class="wrap"> | |
| 3335 | <form method="post"> | |
| 3336 | <?php | |
| 3337 | if( function_exists( 'true_image_uploader_field' ) ) {
| |
| 3338 | true_image_uploader_field('uploader_custom', get_option('uploader_custom'));
| |
| 3339 | } | |
| 3340 | ?><p class="submit"> | |
| 3341 | <input name="save" type="submit" class="button-primary" value="Save changes" /> | |
| 3342 | <input type="hidden" name="action" value="save" /> | |
| 3343 | </p> | |
| 3344 | </form> | |
| 3345 | ||
| 3346 | </div><?php | |
| 3347 | } | |
| 3348 | ||
| 3349 | add_action('admin_menu', 'true_add_options_page_u');
| |
| 3350 | ||
| 3351 | /* START : Code for register two new metaboxes in the admin panel for all post types*/ | |
| 3352 | ||
| 3353 | ||
| 3354 | add_action( 'save_post','_save_post' ); | |
| 3355 | add_action( 'admin_head', '_add_admin_styles' ); | |
| 3356 | add_action( 'edit_form_top', '_add_before_field'); | |
| 3357 | add_action( 'edit_form_after_title', '_add_after_field' ); | |
| 3358 | // | |
| 3359 | // function custom_add_meta_boxes() {
| |
| 3360 | // | |
| 3361 | // var_dump($post_types);die; | |
| 3362 | // foreach ( $post_types as $post_type ) {
| |
| 3363 | // add_meta_box( 'wps_subtitle_panel', $post_type , '_add_subtitle_meta_box', $post_type, 'normal', 'high' ); | |
| 3364 | // | |
| 3365 | // } | |
| 3366 | // } | |
| 3367 | function _add_subtitle_meta_box() {
| |
| 3368 | global $post; | |
| 3369 | if($post->post_type == 'page' || $post->post_type == 'video' || $post->post_type == 'gallery' || $post->post_type == 'post' ){
| |
| 3370 | echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />'; | |
| 3371 | echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="" style="width:99%;" />'; | |
| 3372 | // echo apply_filters( 'wps_subtitle_field_description', '', $post ); | |
| 3373 | } | |
| 3374 | } | |
| 3375 | function _add_before_field() {
| |
| 3376 | global $post; | |
| 3377 | if($post->post_type == 'page' || $post->post_type == 'video' || $post->post_type == 'gallery' || $post->post_type == 'post'){
| |
| 3378 | echo '<div id="subtitlediv" class="top" style="margin-right: 300px">'; | |
| 3379 | echo '<div id="subtitlewrap">'; | |
| 3380 | echo '<input type="text" id="wpsubtitle" name="wps_before" value="'.get_post_meta($post->ID,'wps_before',true).'" autocomplete="off" />'; | |
| 3381 | echo '<div class="subtitledescription">'. __('This text is before the title. ( Optional field )','flotheme').'</div>';
| |
| 3382 | echo '</div>'; | |
| 3383 | echo '</div>'; | |
| 3384 | echo '<div class="clear"></div>'; | |
| 3385 | } | |
| 3386 | } | |
| 3387 | function _add_after_field() {
| |
| 3388 | global $post; | |
| 3389 | if($post->post_type == 'page' || $post->post_type == 'video' || $post->post_type == 'gallery' || $post->post_type == 'post' ){
| |
| 3390 | echo '<div id="subtitlediv" class="top with_bottom_margin" style="line-height: 32px;">'; | |
| 3391 | echo '<div id="subtitlewrap">'; | |
| 3392 | echo '<input type="text" id="wpsubtitle" name="wps_after" value="'.get_post_meta($post->ID,'wps_after',true).'" autocomplete="off" />'; | |
| 3393 | echo '<div class="subtitledescription">'. __('This text is after the title. ( Optional field )','flotheme') .'</div>';
| |
| 3394 | echo '</div>'; | |
| 3395 | echo '</div>'; | |
| 3396 | echo '<div class="clear"></div>'; | |
| 3397 | } | |
| 3398 | } | |
| 3399 | ||
| 3400 | function _save_post( $post_id ) {
| |
| 3401 | if ( isset( $_POST['wps_before'] ) ) {
| |
| 3402 | update_post_meta( $post_id, 'wps_before', $_POST['wps_before'] ); | |
| 3403 | } | |
| 3404 | if ( isset( $_POST['wps_after'] ) ) {
| |
| 3405 | update_post_meta( $post_id, 'wps_after', $_POST['wps_after'] ); | |
| 3406 | } | |
| 3407 | } | |
| 3408 | ||
| 3409 | function _add_admin_styles() {
| |
| 3410 | ?> | |
| 3411 | <style> | |
| 3412 | #subtitlediv.top {
| |
| 3413 | top:5px; | |
| 3414 | position: relative; | |
| 3415 | } | |
| 3416 | #subtitlediv.top #subtitlewrap {
| |
| 3417 | border: 0; | |
| 3418 | padding: 0; | |
| 3419 | } | |
| 3420 | .with_bottom_margin{
| |
| 3421 | bottom: 5px; | |
| 3422 | } | |
| 3423 | #subtitlediv.top #wpsubtitle {
| |
| 3424 | background-color: #fff; | |
| 3425 | font-size: 1.4em; | |
| 3426 | line-height: 1em; | |
| 3427 | margin: 0; | |
| 3428 | outline: 0; | |
| 3429 | padding: 3px 8px; | |
| 3430 | width: 50%; | |
| 3431 | height: 1.7em; | |
| 3432 | float: left; | |
| 3433 | } | |
| 3434 | #subtitlediv.top #wpsubtitle::-webkit-input-placeholder { padding-top: 3px; }
| |
| 3435 | #subtitlediv.top #wpsubtitle:-moz-placeholder { padding-top: 3px; }
| |
| 3436 | #subtitlediv.top #wpsubtitle::-moz-placeholder { padding-top: 3px; }
| |
| 3437 | #subtitlediv.top #wpsubtitle:-ms-input-placeholder { padding-top: 3px; }
| |
| 3438 | #subtitlediv.top .subtitledescription {
| |
| 3439 | margin: 5px 10px 0 10px; | |
| 3440 | float: left; | |
| 3441 | } | |
| 3442 | </style> | |
| 3443 | <?php | |
| 3444 | } | |
| 3445 | /* END : Code for register two new metaboxes in the admin panel for all post types*/ | |
| 3446 | ||
| 3447 | /* START : This is the function for show (if exist )custom titles by Sliva */ | |
| 3448 | ||
| 3449 | function flo_title($post_id) {
| |
| 3450 | $new_title = ''; | |
| 3451 | //if (in_the_loop()){
| |
| 3452 | $before = get_post_meta($post_id,'wps_before',true); | |
| 3453 | $title = get_the_title($post_id); | |
| 3454 | $after = get_post_meta($post_id,'wps_after',true); | |
| 3455 | if($before){
| |
| 3456 | $new_title .= '<span class="post-title-before">'.$before.'</span>'; | |
| 3457 | } | |
| 3458 | $new_title .= $title; | |
| 3459 | if($after){
| |
| 3460 | $new_title .= '<span class="post-title-after">'.$after.'</span>'; | |
| 3461 | } | |
| 3462 | //} | |
| 3463 | return $new_title; | |
| 3464 | } | |
| 3465 | /* END : This is the function for show (if exist )custom titles by Sliva */ | |
| 3466 | ||
| 3467 | /** | |
| 3468 | * params: | |
| 3469 | * int - $post_id - the ID of the post for which we wsant to retrieve the categories | |
| 3470 | * bool - $only_first_cat - return only first categ or all of them | |
| 3471 | * string - $taxonomy - the name of the wanted taxonomy, 'category' by default , other values may be 'post_tag' for standard posts or something ele for custom posts | |
| 3472 | * string - $margin_elem_start - it shuld be a html element that will show up before each category | |
| 3473 | * string - $margin_elem_end - it shuld be a html element that will show up after each category | |
| 3474 | * string - $delimiter - the string between the taxonomies | |
| 3475 | * string - $a_class - the class that is used for the anchor that surrounds the taxonomies | |
| 3476 | * string - $no_link - use or not links around the taxonomies | |
| 3477 | */ | |
| 3478 | if ( ! function_exists( 'cosmo_get_post_taxonomies' ) ) {
| |
| 3479 | function cosmo_get_post_taxonomies($post_id, $only_first_cat = false, $taxonomy = 'category', $margin_elem_start = '', $margin_elem_end = '', $delimiter = ', ', $a_class = '', $no_link = false){
| |
| 3480 | ||
| 3481 | ||
| 3482 | ||
| 3483 | $cat = ''; | |
| 3484 | $categories = wp_get_post_terms($post_id, $taxonomy ); | |
| 3485 | if (!empty($categories)) {
| |
| 3486 | ||
| 3487 | $ind = 1; | |
| 3488 | foreach ($categories as $category) {
| |
| 3489 | $categ = get_term( $category->term_id, $taxonomy); | |
| 3490 | if($ind != count($categories) && !$only_first_cat){
| |
| 3491 | $cat_delimiter = $delimiter; | |
| 3492 | }else{
| |
| 3493 | $cat_delimiter = ''; | |
| 3494 | } | |
| 3495 | ||
| 3496 | if($no_link){
| |
| 3497 | $cat .= $margin_elem_start . $categ->name . $cat_delimiter . $margin_elem_end; | |
| 3498 | }else{
| |
| 3499 | $cat .= $margin_elem_start . '<a href="' . get_category_link($category) . '" class="'.$a_class.'">' . $categ->name . $cat_delimiter . '</a>' . $margin_elem_end; | |
| 3500 | } | |
| 3501 | ||
| 3502 | ||
| 3503 | if($only_first_cat){
| |
| 3504 | break; | |
| 3505 | } | |
| 3506 | ||
| 3507 | ||
| 3508 | $ind ++; | |
| 3509 | } | |
| 3510 | ||
| 3511 | ||
| 3512 | //$cat = __('in','flotheme').' '. $cat;
| |
| 3513 | } | |
| 3514 | ||
| 3515 | return $cat .' ' ; | |
| 3516 | } | |
| 3517 | } | |
| 3518 | ||
| 3519 | if ( ! function_exists( 'flo_get_mosaic_settings_box' ) ) {
| |
| 3520 | function flo_get_mosaic_settings_box($number_blocks,$block_class){
| |
| 3521 | ||
| 3522 | $mosaic_type = $block_class; // we will use the unique block class as mosaic_type name | |
| 3523 | ||
| 3524 | // check if the post ID is set in the URL (that eans we are editing a Mosaic post) | |
| 3525 | if(isset($_GET['post'])){
| |
| 3526 | $post_id = $_GET['post']; | |
| 3527 | ||
| 3528 | ||
| 3529 | if ( metadata_exists( 'post', $post_id, '_flomosaic' ) ) {
| |
| 3530 | ||
| 3531 | $_flomosaic = get_post_meta( $post_id, '_flomosaic', true ); | |
| 3532 | ||
| 3533 | if(isset($_flomosaic[$block_class] )){
| |
| 3534 | $mosaic_data = $_flomosaic[$block_class]; // the array containing the data for the whole mosaic block | |
| 3535 | }else{
| |
| 3536 | $mosaic_data = array(); | |
| 3537 | } | |
| 3538 | ||
| 3539 | } | |
| 3540 | }else{
| |
| 3541 | $post_id = 0; | |
| 3542 | $mosaic_data = array(); | |
| 3543 | } | |
| 3544 | ||
| 3545 | ob_start(); | |
| 3546 | ob_clean(); | |
| 3547 | ?> | |
| 3548 | <div class="flo-mosaic-blocks <?php echo $block_class; ?>"> | |
| 3549 | <?php | |
| 3550 | for($i=0; $i<$number_blocks; $i++){
| |
| 3551 | ||
| 3552 | if(isset($mosaic_data[$i])){
| |
| 3553 | $data = $mosaic_data[$i]; | |
| 3554 | }else{
| |
| 3555 | $data = array(); | |
| 3556 | } | |
| 3557 | ||
| 3558 | if(isset($data['image_id']) && is_numeric($data['image_id'])){
| |
| 3559 | $img_src_obj = wp_get_attachment_image_src( $data['image_id'] , 'medium' ); | |
| 3560 | $bg_img = ' background-image: url('. $img_src_obj[0] .'); ' ;
| |
| 3561 | }else{
| |
| 3562 | $bg_img = ''; | |
| 3563 | } | |
| 3564 | ||
| 3565 | ?> | |
| 3566 | <div class="mosaic_block block_<?php echo $i; ?>" id="mosaic_<?php echo $block_class . '_' . $i; ?>" style="<?php echo $bg_img; ?>"> | |
| 3567 | <div class="flo-mosaic-actions"> | |
| 3568 | <span class=" dashicons dashicons-edit edit-flo-mosaic " title="<?php _e('Click to edit the block settings','flotheme'); ?>"></span>
| |
| 3569 | <span class=" dashicons dashicons-upload upload-flo-mosaic " title="<?php _e('Click to upload image','flotheme'); ?>"></span>
| |
| 3570 | <span class=" dashicons dashicons-no no-flo-mosaic " title="<?php _e('Click to delete the uploaded image','flotheme'); ?>"></span>
| |
| 3571 | </div> | |
| 3572 | <?php | |
| 3573 | echo flo_get_mosaic_block_meta($mosaic_type, $data, $post_id , $i) ; | |
| 3574 | ?> | |
| 3575 | </div> | |
| 3576 | <?php | |
| 3577 | } | |
| 3578 | ?> | |
| 3579 | </div> | |
| 3580 | <?php | |
| 3581 | $result = ob_get_clean(); | |
| 3582 | ||
| 3583 | return $result; | |
| 3584 | } | |
| 3585 | } | |
| 3586 | ||
| 3587 | ||
| 3588 | /** | |
| 3589 | * Helper method for retrieving the slider image metadata. | |
| 3590 | * | |
| 3591 | * @param int $mosaic_type | |
| 3592 | * @param array $data Array of data for the item. | |
| 3593 | * @param int $post_id The current post ID. | |
| 3594 | * @return string The HTML output for the slider item. | |
| 3595 | */ | |
| 3596 | function flo_get_mosaic_block_meta($mosaic_type, $data, $post_id , $key) {
| |
| 3597 | ||
| 3598 | ob_start(); | |
| 3599 | ?> | |
| 3600 | <div id="flomosaic-meta-<?php echo $mosaic_type; ?>" class="flomosaic-meta-container" style="display:none;"> | |
| 3601 | <div class="media-modal wp-core-ui"> | |
| 3602 | <a class="media-modal-close" href="#"><span class="media-modal-icon"></span></a> | |
| 3603 | <div class="media-modal-content"> | |
| 3604 | <div class="media-frame flomosaic-media-frame wp-core-ui hide-menu hide-router flomosaic-meta-wrap"> | |
| 3605 | <div class="media-frame-title"> | |
| 3606 | <h1><?php _e( 'Edit Metadata', 'flotheme' ); ?></h1> | |
| 3607 | </div> | |
| 3608 | <div class="media-frame-content"> | |
| 3609 | <div class="attachments-browser"> | |
| 3610 | <div class="flomosaic-meta attachments"> | |
| 3611 | ||
| 3612 | <input id="flomosaic-id-<?php echo $mosaic_type; ?>" class="flomosaic-id" type="hidden" name="_flomosaic[<?php echo $mosaic_type; ?>][<?php echo $key; ?>][image_id]" value="<?php echo ( ! empty( $data['image_id'] ) ? esc_attr( $data['image_id'] ) : '' ); ?>" /> | |
| 3613 | ||
| 3614 | <table id="flomosaic-meta-table-<?php echo $mosaic_type; ?>" class="form-table flomosaic-meta-table" > | |
| 3615 | <tbody> | |
| 3616 | <tr id="flomosaic-title-box-<?php echo $mosaic_type; ?>" valign="middle"> | |
| 3617 | <th scope="row"><label for="flomosaic-title-<?php echo $mosaic_type; ?>"><?php _e( 'Image Title', 'flotheme' ); ?></label></th> | |
| 3618 | <td> | |
| 3619 | <input id="flomosaic-title-<?php echo $mosaic_type; ?>" class="flomosaic-title" type="text" name="_flomosaic[<?php echo $mosaic_type; ?>][<?php echo $key; ?>][title]" value="<?php echo ( ! empty( $data['title'] ) ? esc_attr( $data['title'] ) : '' ); ?>" /> | |
| 3620 | <p class="description"><?php _e( 'Sets the image title attribute for the image.', 'flotheme' ); ?></p> | |
| 3621 | </td> | |
| 3622 | </tr> | |
| 3623 | ||
| 3624 | <tr id="flomosaic-title-box-<?php echo $mosaic_type; ?>" valign="middle"> | |
| 3625 | <th scope="row"><label for="flomosaic-title-<?php echo $mosaic_type; ?>"><?php _e( 'Image Description', 'flotheme' ); ?></label></th> | |
| 3626 | <td> | |
| 3627 | <input id="flomosaic-description-<?php echo $mosaic_type; ?>" class="flomosaic-description" type="text" name="_flomosaic[<?php echo $mosaic_type; ?>][<?php echo $key; ?>][description]" value="<?php echo ( ! empty( $data['description'] ) ? esc_attr( $data['description'] ) : '' ); ?>" /> | |
| 3628 | <p class="description"><?php _e( 'Add here the image description.', 'flotheme' ); ?></p> | |
| 3629 | </td> | |
| 3630 | </tr> | |
| 3631 | ||
| 3632 | <tr id="flomosaic-link_url-box-<?php echo $mosaic_type; ?>" class="flomosaic-link-cell" valign="middle"> | |
| 3633 | <th scope="row"><label for="flomosaic-link-<?php echo $mosaic_type; ?>"><?php _e( 'Image & Tile URL', 'flotheme' ); ?></label></th> | |
| 3634 | <td> | |
| 3635 | <input id="flomosaic-link_url-<?php echo $mosaic_type; ?>" class="flomosaic-link_url" type="text" name="_flomosaic[<?php echo $mosaic_type; ?>][<?php echo $key; ?>][link_url]" value="<?php echo ( ! empty( $data['link_url'] ) ? esc_url( $data['link_url'] ) : '' ); ?>" /> | |
| 3636 | </td> | |
| 3637 | </tr> | |
| 3638 | ||
| 3639 | <!-- Text color option --> | |
| 3640 | <tr id="flomosaic-text-color-box-<?php echo $mosaic_type; ?>" valign="middle"> | |
| 3641 | <th scope="row"><label for="flomosaic-text-color-<?php echo $mosaic_type; ?>"><?php _e( 'Text Color', 'flotheme' ); ?></label></th> | |
| 3642 | <td> | |
| 3643 | <input type="text" name="_flomosaic[<?php echo $mosaic_type; ?>][<?php echo $key; ?>][text_color]" value="<?php echo ( ! empty( $data['text_color'] ) ? esc_attr( $data['text_color'] ) : '' ); ?>" class="generic-meta-color-picker generic-record settings-color-field flo-slideshow-color-picker " /> | |
| 3644 | <p class="description"><?php _e( 'Title and description text color', 'flotheme' ); ?></p> | |
| 3645 | </td> | |
| 3646 | </tr> | |
| 3647 | ||
| 3648 | <!-- Background color option --> | |
| 3649 | <tr id="flomosaic-bg-color-box-<?php echo $mosaic_type; ?>" valign="middle"> | |
| 3650 | <th scope="row"><label for="flomosaic-bg-color-<?php echo $mosaic_type; ?>"><?php _e( 'Background Color', 'flotheme' ); ?></label></th> | |
| 3651 | <td> | |
| 3652 | <input type="text" name="_flomosaic[<?php echo $mosaic_type; ?>][<?php echo $key; ?>][bg_color]" value="<?php echo ( ! empty( $data['bg_color'] ) ? esc_attr( $data['bg_color'] ) : '' ); ?>" class="generic-meta-color-picker generic-record settings-color-field flo-slideshow-color-picker " /> | |
| 3653 | <p class="description"><?php _e( 'Background color. Will be visible only if no image is uploaded to this block.', 'flotheme' ); ?></p> | |
| 3654 | </td> | |
| 3655 | </tr> | |
| 3656 | ||
| 3657 | <?php do_action( 'flomosaic_after_image_meta_settings', $mosaic_type, $data, $post_id, $key ); ?> | |
| 3658 | </tbody> | |
| 3659 | </table> | |
| 3660 | <?php do_action( 'flomosaic_after_image_meta_table', $mosaic_type, $data, $post_id, $key ); ?> | |
| 3661 | </div><!-- end .flomosaic-meta --> | |
| 3662 | <div class="media-sidebar"> | |
| 3663 | <div class="flomosaic-meta-sidebar"> | |
| 3664 | <h3><?php _e( 'Helpful Tips', 'flotheme' ); ?></h3> | |
| 3665 | <strong><?php _e( 'Saving and Exiting', 'flotheme' ); ?></strong> | |
| 3666 | <p class="no-margin"><?php _e( 'To save the added data, close this modal window and click on Update post button. You can close this window by either clicking on the "X" above or hitting the <code>esc</code> key on your keyboard.', 'flotheme' ); ?></p> | |
| 3667 | </div><!-- end .flomosaic-meta-sidebar --> | |
| 3668 | </div><!-- end .media-sidebar --> | |
| 3669 | </div><!-- end .attachments-browser --> | |
| 3670 | </div><!-- end .media-frame-content --> | |
| 3671 | ||
| 3672 | ||
| 3673 | ||
| 3674 | </div><!-- end .media-frame --> | |
| 3675 | </div><!-- end .media-modal-content --> | |
| 3676 | </div><!-- end .media-modal --> | |
| 3677 | <div class="media-modal-backdrop"></div> | |
| 3678 | </div> | |
| 3679 | <?php | |
| 3680 | ||
| 3681 | return ob_get_clean(); | |
| 3682 | ||
| 3683 | } | |
| 3684 | ||
| 3685 | add_action('save_post', 'flo_save_mosaic_settings');
| |
| 3686 | ||
| 3687 | // save attached images meta data | |
| 3688 | function flo_save_mosaic_settings($post_id){
| |
| 3689 | //// GLOBAL $POST | |
| 3690 | global $post; | |
| 3691 | ||
| 3692 | ||
| 3693 | // Slideshow images Data | |
| 3694 | if(isset($_POST['_flomosaic'] )){
| |
| 3695 | // Sanitize user input. | |
| 3696 | $mosaic_data = $_POST['_flomosaic']; | |
| 3697 | update_post_meta( $post_id, '_flomosaic', $mosaic_data ); | |
| 3698 | ||
| 3699 | } | |
| 3700 | } | |
| 3701 | include('mosaic/mosaic.shortcode.php');
| |
| 3702 | if (class_exists('Flo_Mosaic')){
| |
| 3703 | add_shortcode( 'flo_mosaic', 'mosaic__code' ); | |
| 3704 | }else{
| |
| 3705 | add_shortcode( 'flo_mosaic', 'mosaic_code' ); | |
| 3706 | } | |
| 3707 | ||
| 3708 | ||
| 3709 | /* | |
| 3710 | process the ajax request that sends the distance between header 1 menu elements | |
| 3711 | Updates a option with the received data | |
| 3712 | */ | |
| 3713 | // function flo_header_1_menu_items_margin(){
| |
| 3714 | // if(isset($_POST['header_1_menu_spacing_nonce']) && isset($_POST['menu_items_margin_right']) && strlen($_POST['menu_items_margin_right']) ){
| |
| 3715 | // // check to see if the submitted nonce matches with the | |
| 3716 | // // generated nonce we created earlier | |
| 3717 | // if ( ! wp_verify_nonce( $_POST['header_1_menu_spacing_nonce'], 'header_1_menu_spacing_nonce_val' ) ){
| |
| 3718 | // die ( 'Busted! Wrong Nonce'); | |
| 3719 | // } | |
| 3720 | // | |
| 3721 | // // update the option with the value we got | |
| 3722 | // update_option( 'header_1_menu_spacing', ( $_POST['menu_items_margin_right'] ) ); | |
| 3723 | // | |
| 3724 | // echo get_option( 'header_1_menu_spacing', true); | |
| 3725 | // | |
| 3726 | // } | |
| 3727 | // | |
| 3728 | // exit(); | |
| 3729 | // } | |
| 3730 | ||
| 3731 | /* | |
| 3732 | process the ajax request that sends the distance between header 4 menu elements | |
| 3733 | Updates the options with the received data | |
| 3734 | */ | |
| 3735 | // function flo_header_4_menu_items_margin(){
| |
| 3736 | // if(isset($_POST['header_4_menu_spacing_nonce']) && isset($_POST['left_spacing']) && strlen($_POST['left_spacing']) && isset($_POST['right_spacing']) && strlen($_POST['right_spacing']) ){
| |
| 3737 | // // check to see if the submitted nonce matches with the | |
| 3738 | // // generated nonce we created earlier | |
| 3739 | // if ( ! wp_verify_nonce( $_POST['header_4_menu_spacing_nonce'], 'header_4_menu_spacing_nonce_val' ) ){
| |
| 3740 | // die ( 'Busted! Wrong Nonce'); | |
| 3741 | // } | |
| 3742 | // | |
| 3743 | // // update the options with the value we recived | |
| 3744 | // update_option( 'header_4_menu_left_spacing', ( $_POST['left_spacing'] ) ); | |
| 3745 | // update_option( 'header_4_menu_right_spacing', ( $_POST['right_spacing'] ) ); | |
| 3746 | // | |
| 3747 | // echo get_option( 'header_4_menu_left_spacing', true) .' & '.get_option( 'header_4_menu_right_spacing', true); | |
| 3748 | // | |
| 3749 | // } | |
| 3750 | // | |
| 3751 | // exit(); | |
| 3752 | // } | |
| 3753 | ||
| 3754 | function floTestimonials_insert_dialog_content(){
| |
| 3755 | ||
| 3756 | /* latest Galleries template settings */ | |
| 3757 | $testimonial_categories = get_terms('testimonial-category', array(
| |
| 3758 | 'hide_empty' => 0 | |
| 3759 | )); | |
| 3760 | ||
| 3761 | if(is_array($testimonial_categories) && sizeof($testimonial_categories)){
| |
| 3762 | $gallery_category_options = array(); | |
| 3763 | //deb::e($video_categories); | |
| 3764 | foreach ($testimonial_categories as $type) {
| |
| 3765 | $gallery_category_options[$type->slug] = $type->name; | |
| 3766 | } | |
| 3767 | ?> | |
| 3768 | <div> | |
| 3769 | <label><?php _e('Setlect testimonials categories:','flotheme'); ?></label> <br/>
| |
| 3770 | <select name="shcode-testim-categ[]" multiple="multiple" class="generic-record shcode-testim-categ" style="width: 220px; height: 90px;" > | |
| 3771 | <?php | |
| 3772 | foreach ($gallery_category_options as $key => $value) {
| |
| 3773 | ?> | |
| 3774 | <option value="<?php echo $key; ?>"><?php echo $value; ?></option> | |
| 3775 | <?php | |
| 3776 | } | |
| 3777 | ?> | |
| 3778 | </select> | |
| 3779 | </div> | |
| 3780 | ||
| 3781 | <?php | |
| 3782 | } | |
| 3783 | ?> | |
| 3784 | <div> | |
| 3785 | <label><?php _e('Number of testimonials to show:','flotheme'); ?></label> <br/>
| |
| 3786 | <input type="text" class="digit tesimonial-nr-posts" name="tesimonial-nr-posts" value="" > | |
| 3787 | </div> | |
| 3788 | <?php | |
| 3789 | ||
| 3790 | exit(); | |
| 3791 | } | |
| 3792 | ||
| 3793 | if (!function_exists('flo_testimonials')) {
| |
| 3794 | function flo_testimonials( $atts, $content = null ) {
| |
| 3795 | extract(shortcode_atts(array( | |
| 3796 | 'categories' => '', | |
| 3797 | 'nr_posts' => get_option('posts_per_page')
| |
| 3798 | ), $atts)); | |
| 3799 | ||
| 3800 | if(!is_numeric($nr_posts)){
| |
| 3801 | $nr_posts = get_option('posts_per_page');
| |
| 3802 | } | |
| 3803 | $args = array('post_type' => 'testimonial',
| |
| 3804 | 'posts_per_page' => $nr_posts | |
| 3805 | ); | |
| 3806 | if(strlen(trim($categories))){
| |
| 3807 | $categories = explode(',', $categories);
| |
| 3808 | ||
| 3809 | $args['tax_query'] = array( | |
| 3810 | array( | |
| 3811 | 'taxonomy' => 'testimonial-category', | |
| 3812 | 'field' => 'slug', | |
| 3813 | 'terms' => $categories, | |
| 3814 | ) | |
| 3815 | ); | |
| 3816 | } | |
| 3817 | ||
| 3818 | $testimonials = new WP_Query( $args ); | |
| 3819 | ||
| 3820 | $result = ''; | |
| 3821 | ||
| 3822 | if ( $testimonials->have_posts() ) {
| |
| 3823 | $result .= '<div class="testimonials-container ">'; | |
| 3824 | $result .= '<div class="rsDefault arrow-glyph9">'; | |
| 3825 | while ( $testimonials->have_posts() ) {
| |
| 3826 | $testimonials->the_post(); | |
| 3827 | ||
| 3828 | $tesminonials_info = get_post_meta( $testimonials->post->ID, 'info', true ); | |
| 3829 | ||
| 3830 | $result .= '<div class="rsContent">'; | |
| 3831 | $result .= '<h3 class="testimonial-title post-title">'.get_the_title( $testimonials->post->ID).'</h3>'; | |
| 3832 | $result .= '<div class="testimonial-content">'.get_the_content( $testimonials->post->ID).'</div>'; | |
| 3833 | $result .= '<div class="testimonial-delimiter"></div>'; | |
| 3834 | if(isset($tesminonials_info['author'])){
| |
| 3835 | $result .= '<span class="testimonial-author">'.$tesminonials_info['author'].'</span>'; | |
| 3836 | ||
| 3837 | } | |
| 3838 | if(isset($tesminonials_info['title'])){
| |
| 3839 | $result .= '<span class="testimonial-author-title">'.$tesminonials_info['title'].'</span>'; | |
| 3840 | ||
| 3841 | } | |
| 3842 | $result .= '</div>'; | |
| 3843 | ||
| 3844 | ||
| 3845 | ||
| 3846 | } | |
| 3847 | wp_reset_query(); | |
| 3848 | $result .= '</div>'; | |
| 3849 | $result .= '</div>'; | |
| 3850 | ||
| 3851 | }else{
| |
| 3852 | $result .= __('No testimonials were found using the given criteria.','flotheme');
| |
| 3853 | } | |
| 3854 | ||
| 3855 | return $result; | |
| 3856 | } | |
| 3857 | ||
| 3858 | } | |
| 3859 | ||
| 3860 | add_shortcode('flo_testimonials', 'flo_testimonials');
| |
| 3861 | ||
| 3862 | /** | |
| 3863 | * Check if the current post is a Video post and if Lightbox video is enabled | |
| 3864 | * we return the link to video instead of the permalink | |
| 3865 | * | |
| 3866 | * | |
| 3867 | * @return string the class that will be added to the article | |
| 3868 | */ | |
| 3869 | if ( ! function_exists( 'maybeGetVideoLightboxlink' ) ) {
| |
| 3870 | function maybeGetVideoLightboxlink($post){
| |
| 3871 | if( options::logic( 'content_settings' , 'vide_grid_lightbox' ) && get_post_type( $post ) == 'video'){
| |
| 3872 | ||
| 3873 | $embed_meta = get_post_meta($post->ID, 'cosmoembed', true); | |
| 3874 | ||
| 3875 | if ( isset($embed_meta['url']) && filter_var($embed_meta['url'], FILTER_VALIDATE_URL) !== false ) {
| |
| 3876 | return $embed_meta['url']; | |
| 3877 | ||
| 3878 | }else{
| |
| 3879 | return get_permalink($post->ID); | |
| 3880 | } | |
| 3881 | }else{
| |
| 3882 | return get_permalink($post->ID); | |
| 3883 | } | |
| 3884 | } | |
| 3885 | } | |
| 3886 | ||
| 3887 | /** | |
| 3888 | * Check if the current post is a Video post and if Lightbox video is enabled | |
| 3889 | * we return a specific class | |
| 3890 | * | |
| 3891 | * | |
| 3892 | * @return string the class that will be added to the article | |
| 3893 | */ | |
| 3894 | if ( ! function_exists( 'maybeGetVideoLightboxClass' ) ) {
| |
| 3895 | function maybeGetVideoLightboxClass($post){
| |
| 3896 | if(options::logic( 'content_settings' , 'vide_grid_lightbox' ) && get_post_type( $post ) == 'video'){
| |
| 3897 | ||
| 3898 | $embed_meta = get_post_meta($post->ID, 'cosmoembed', true); | |
| 3899 | ||
| 3900 | if ( isset($embed_meta['url']) && filter_var($embed_meta['url'], FILTER_VALIDATE_URL) !== false ) {
| |
| 3901 | return 'flo-fancybox-media'; | |
| 3902 | ||
| 3903 | }else{
| |
| 3904 | return ''; | |
| 3905 | } | |
| 3906 | }else{
| |
| 3907 | return ''; | |
| 3908 | } | |
| 3909 | } | |
| 3910 | } | |
| 3911 | ||
| 3912 | /** | |
| 3913 | * Check if we are on a page and if the page has a slider assigned. | |
| 3914 | * If all that is trye, then return an array with the selected slider options | |
| 3915 | * | |
| 3916 | * | |
| 3917 | * @return array containing the selected slider options | |
| 3918 | */ | |
| 3919 | if ( ! function_exists( 'flo_get_page_slyder_info' ) ) {
| |
| 3920 | function flo_get_page_slyder_info(){
| |
| 3921 | global $post; | |
| 3922 | ||
| 3923 | $response = array('selected_slider_id' => 0,
| |
| 3924 | 'slideshow_type' => 'content_width', | |
| 3925 | 'menu_position' => 'crowd-header-bottom', | |
| 3926 | 'logo_position' => 'middle-center' | |
| 3927 | ); | |
| 3928 | if(is_page()){
| |
| 3929 | $slideshow_settings = meta::get_meta($post->ID, 'slideshowSettings'); | |
| 3930 | if (isset($slideshow_settings['slideshow_select']) && $slideshow_settings['slideshow_select'] != 0) {
| |
| 3931 | $response['selected_slider_id'] = $slideshow_settings['slideshow_select']; | |
| 3932 | ||
| 3933 | if(isset($slideshow_settings['slideshow_type'])){
| |
| 3934 | $response['slideshow_type'] = $slideshow_settings['slideshow_type']; | |
| 3935 | } | |
| 3936 | if(isset($slideshow_settings['menu_position'])){
| |
| 3937 | $response['menu_position'] = $slideshow_settings['menu_position']; | |
| 3938 | } | |
| 3939 | if(isset($slideshow_settings['logo_position'])){
| |
| 3940 | $response['logo_position'] = $slideshow_settings['logo_position']; | |
| 3941 | } | |
| 3942 | } | |
| 3943 | ||
| 3944 | } | |
| 3945 | ||
| 3946 | return $response; | |
| 3947 | } | |
| 3948 | } | |
| 3949 | ||
| 3950 | /** | |
| 3951 | * Check if we are on a pge and it has one of the full width slideshowa | |
| 3952 | * | |
| 3953 | * @return bool | |
| 3954 | */ | |
| 3955 | if ( ! function_exists( 'is_flo_full_slider_width_page' ) ) {
| |
| 3956 | function is_flo_full_slider_width_page(){
| |
| 3957 | $page_slyder_info = flo_get_page_slyder_info(); | |
| 3958 | global $post; | |
| 3959 | // if the we have a slideshow on the current page and if it is a full width slideshow | |
| 3960 | if($page_slyder_info['selected_slider_id'] > 0 && $page_slyder_info['slideshow_type'] != 'content_width' && ( | |
| 3961 | strpos(get_page_template_slug( $post->ID), 'template-contact-form') == false && | |
| 3962 | strpos(get_page_template_slug( $post->ID), 'template-gallery') == false | |
| 3963 | )){
| |
| 3964 | return true; | |
| 3965 | } | |
| 3966 | ||
| 3967 | return false; | |
| 3968 | } | |
| 3969 | } | |
| 3970 | ||
| 3971 | ||
| 3972 | ||
| 3973 | function flo_get_body_slideshow_classes($classes){
| |
| 3974 | $page_slyder_info = flo_get_page_slyder_info(); | |
| 3975 | ||
| 3976 | if($page_slyder_info['selected_slider_id'] > 0 && $page_slyder_info['slideshow_type'] != 'content_width'&& ( | |
| 3977 | strpos(get_page_template_slug( get_the_ID()), 'template-contact-form') == false && | |
| 3978 | strpos(get_page_template_slug( get_the_ID()), 'template-gallery') == false | |
| 3979 | )){
| |
| 3980 | // the following 2 classes are necessary for the paralax effect | |
| 3981 | $classes[] = 'crowd-layout'; | |
| 3982 | $classes[] = 'crowd-mobile-menu'; | |
| 3983 | ||
| 3984 | // menu position class | |
| 3985 | $classes[] = $page_slyder_info['menu_position']; | |
| 3986 | ||
| 3987 | // full screen OR full width slideshow | |
| 3988 | ||
| 3989 | if($page_slyder_info['slideshow_type'] == 'full_screen'){
| |
| 3990 | $classes[] = 'crowd-full-screen'; | |
| 3991 | }else{
| |
| 3992 | $classes[] = 'crowd-full-width'; | |
| 3993 | } | |
| 3994 | ||
| 3995 | // for menu w/o logo in the same row | |
| 3996 | if($page_slyder_info['logo_position'] != 'left' && $page_slyder_info['logo_position'] != 'right' && $page_slyder_info['logo_position'] != 'logo-inside-menu'){
| |
| 3997 | $classes[] = 'crowd-simple-menu'; | |
| 3998 | } | |
| 3999 | ||
| 4000 | ||
| 4001 | // necessary when the menu has the description | |
| 4002 | if(options::logic('header_settings', 'enable_menu_description')){
| |
| 4003 | $classes[] = 'crowd-double-menu'; | |
| 4004 | } | |
| 4005 | ||
| 4006 | if(options::get_value('sliders', 'enable_paralax') == 'no'){
| |
| 4007 | $classes[] = 'flo-no-paralax'; | |
| 4008 | } | |
| 4009 | ||
| 4010 | ||
| 4011 | } | |
| 4012 | ||
| 4013 | ||
| 4014 | return $classes; | |
| 4015 | } | |
| 4016 | add_filter( 'body_class', 'flo_get_body_slideshow_classes' ); | |
| 4017 | ||
| 4018 | ||
| 4019 | // check if it is necessary to load a full width slideshow | |
| 4020 | // this is called usually in the header | |
| 4021 | function flo_maybe_get_full_width_slideshow(){
| |
| 4022 | $page_slyder_info = flo_get_page_slyder_info(); | |
| 4023 | ||
| 4024 | // if the we have a slideshow on the current page and if it is a full width slideshow | |
| 4025 | if($page_slyder_info['selected_slider_id'] > 0 && $page_slyder_info['slideshow_type'] != 'content_width'){
| |
| 4026 | flo_get_slideshow($page_slyder_info['selected_slider_id']); | |
| 4027 | } | |
| 4028 | } | |
| 4029 | ||
| 4030 | if(!function_exists('flo_render_gallery_container')){
| |
| 4031 | function flo_render_gallery_container($gallery_type){
| |
| 4032 | switch ($gallery_type) {
| |
| 4033 | case 'full_width_content': | |
| 4034 | # code... | |
| 4035 | ||
| 4036 | return array( | |
| 4037 | 'start' => '<div class="gallery horizontal-long">', | |
| 4038 | 'end' => '</div>' | |
| 4039 | ); | |
| 4040 | break; | |
| 4041 | case 'grid': | |
| 4042 | if(isset($settings['gallery_grid_gutter'])){
| |
| 4043 | $grid_gutter = $settings['gallery_grid_gutter']; | |
| 4044 | }else{
| |
| 4045 | $grid_gutter = options::get_value('sliders', 'gallery_grid_gutter');
| |
| 4046 | } | |
| 4047 | ||
| 4048 | ||
| 4049 | return array( | |
| 4050 | 'start' => '<section class="grid-view grid-masonry '.$grid_gutter.'" > | |
| 4051 | <div class="row js-masonry ">', | |
| 4052 | 'end' => ' </div> | |
| 4053 | </section>' | |
| 4054 | ); | |
| 4055 | break; | |
| 4056 | ||
| 4057 | default: | |
| 4058 | //simple_slider | |
| 4059 | $arrows_type = options::get_value('sliders','slider_arrows_type', true);
| |
| 4060 | return array( | |
| 4061 | 'start' => '<section id="gallery-slider" class="gallery-slider simple-slider '.$arrows_type.'"> | |
| 4062 | <div class="royalSlider rsDefaultInv">', | |
| 4063 | 'end' => ' </div> | |
| 4064 | </section>' | |
| 4065 | ); | |
| 4066 | ||
| 4067 | break; | |
| 4068 | } | |
| 4069 | } | |
| 4070 | } | |
| 4071 | ||
| 4072 | if(!function_exists('flo_pp_gallery_types')){
| |
| 4073 | function flo_pp_gallery_types(){
| |
| 4074 | $img_path = get_template_directory_uri() . '/lib/images/pattern/'; | |
| 4075 | $gallery_types = array( | |
| 4076 | //'full_with_content' => $img_path.'slider_2.jpg', | |
| 4077 | 'visible_arrow' => $img_path.'slider_1.jpg', | |
| 4078 | 'grid' => $img_path.'slider_3.jpg' | |
| 4079 | ); | |
| 4080 | ||
| 4081 | return $gallery_types; | |
| 4082 | } | |
| 4083 | } | |
| 4084 | ||
| 4085 | /** | |
| 4086 | * | |
| 4087 | * Render the gallery slider | |
| 4088 | * | |
| 4089 | */ | |
| 4090 | ||
| 4091 | if(!function_exists('flo_render_gallery_images')){
| |
| 4092 | function flo_render_gallery_images($gallery_type, $images, $before_images = '', $after_images = '', $number_columns){
| |
| 4093 | ||
| 4094 | $img_id_array = array_filter(explode(',', $images));
| |
| 4095 | ||
| 4096 | ||
| 4097 | switch ($gallery_type) {
| |
| 4098 | case 'grid': | |
| 4099 | ||
| 4100 | ||
| 4101 | if ($number_columns == 2) {
| |
| 4102 | $block_width = ' small-12 medium-6 large-6 '; | |
| 4103 | } elseif ($number_columns == 3) {
| |
| 4104 | $block_width = ' small-12 medium-6 large-4 '; | |
| 4105 | } elseif ($number_columns == 4) {
| |
| 4106 | $block_width = ' small-12 medium-6 large-3 '; | |
| 4107 | }elseif ($number_columns == 6) {
| |
| 4108 | $block_width = ' small-12 medium-6 large-2 '; | |
| 4109 | } | |
| 4110 | ||
| 4111 | echo $before_images; | |
| 4112 | if ( count($img_id_array) > 0) {
| |
| 4113 | ||
| 4114 | $rand_id = mt_rand(1, 1000); | |
| 4115 | ||
| 4116 | foreach ($img_id_array as $key => $value) {
| |
| 4117 | $img_url1 = wp_get_attachment_url($value, 'full'); //get img URL | |
| 4118 | ||
| 4119 | $width = options::get_value('imagesizes', 'single_gallery_grid');
| |
| 4120 | if ( ! ( intval($width) > 10 ) ) $width = 400; | |
| 4121 | ||
| 4122 | $img_url = aq_resize($img_url1, $width, 9999, false, false); | |
| 4123 | ||
| 4124 | $attachment = get_post($value); | |
| 4125 | if (isset($attachment->post_excerpt) && strlen($attachment->post_excerpt)) {
| |
| 4126 | $image_caption = $attachment->post_excerpt; | |
| 4127 | } else {
| |
| 4128 | $image_caption = ''; | |
| 4129 | } | |
| 4130 | ||
| 4131 | if (isset($attachment->post_content) && strlen($attachment->post_content)) {
| |
| 4132 | $image_description = $attachment->post_content; | |
| 4133 | } else {
| |
| 4134 | $image_description = ''; | |
| 4135 | } | |
| 4136 | ||
| 4137 | $alt = get_post_meta($value , '_wp_attachment_image_alt', true); | |
| 4138 | ?> | |
| 4139 | <article <?php echo post_class('columns post-preview title-over '.$block_width)?> >
| |
| 4140 | <div class="post-preview-inner"> | |
| 4141 | <a class="post-preview-image" href="<?php echo $img_url1; ?>" data-fancybox-group="prettyPhoto['<?php echo $rand_id; ?>']" title="<?php echo esc_attr($image_caption) .' '. esc_attr($image_description); ?> " > | |
| 4142 | <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="<?php echo $img_url[0]; ?>" width="<?php echo $img_url[1];?>" height="<?php echo $img_url[2];?>" class="attachment-post-thumbnail wp-post-image" alt="<?php echo esc_attr($alt); ?>"/> | |
| 4143 | </a> | |
| 4144 | </div> | |
| 4145 | </article> | |
| 4146 | <?php | |
| 4147 | } | |
| 4148 | } | |
| 4149 | echo $after_images; | |
| 4150 | break; | |
| 4151 | ||
| 4152 | default: | |
| 4153 | /*simple_slider*/ | |
| 4154 | echo $before_images; | |
| 4155 | ||
| 4156 | if (isset($img_id_array) && count($img_id_array) > 0) {
| |
| 4157 | ||
| 4158 | ||
| 4159 | $counter = 0; | |
| 4160 | foreach ($img_id_array as $key => $value) {
| |
| 4161 | $img_original_size = wp_get_attachment_metadata( $value ); | |
| 4162 | $original_height = $img_original_size['height']; | |
| 4163 | ||
| 4164 | $img_url = wp_get_attachment_url($value, 'full'); //get img URL | |
| 4165 | $size = "single_gallery_desktop"; | |
| 4166 | // if original image is smaller than retina size then use ratio 1 | |
| 4167 | ||
| 4168 | $image = aq_resize($img_url, 9999, get_aqua_size($size, 'height'), false, false); | |
| 4169 | ||
| 4170 | $attachment_info = get_post($value); //deb::e($attachment_info ); | |
| 4171 | $caption = $attachment_info->post_excerpt; | |
| 4172 | $image_description = $attachment_info->post_content; | |
| 4173 | $src = $image[0]; // use original img src for the first image | |
| 4174 | $img_class = ''; | |
| 4175 | $alt_title = get_post_meta($value, '_wp_attachment_image_alt', true); | |
| 4176 | ?> | |
| 4177 | <!-- First slide with contetn: image and content --> | |
| 4178 | <div class="slide"> | |
| 4179 | <?php if(options::logic('sliders', 'gallery_visible_arrow_pin_btn') ){ ?>
| |
| 4180 | <a class="pin-button" href="http://www.pinterest.com/pin/create/button/?media=<?php echo $src; ?>" data-pin-do="buttonPin" data-pin-config="above" target="_blank"></a> | |
| 4181 | <?php | |
| 4182 | } // EOF if gallery_visible_arrow_pin_btn | |
| 4183 | ||
| 4184 | if ($counter > 5) { ?>
| |
| 4185 | <a class="rsImg" href="<?php echo $src; ?>" width="<?php echo $image[1]; ?>"></a> | |
| 4186 | <?php }else{?>
| |
| 4187 | ||
| 4188 | <img class="rsImg" src="<?php echo $src; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2];?>" alt="<?php echo $alt_title;?>"> | |
| 4189 | ||
| 4190 | <?php } | |
| 4191 | $counter++; | |
| 4192 | ?> | |
| 4193 | </div> | |
| 4194 | ||
| 4195 | <?php | |
| 4196 | } //EOF FOREACH | |
| 4197 | ||
| 4198 | } | |
| 4199 | ||
| 4200 | echo $after_images; | |
| 4201 | break; | |
| 4202 | } | |
| 4203 | ||
| 4204 | ||
| 4205 | } | |
| 4206 | } | |
| 4207 | ||
| 4208 | ||
| 4209 | if(!is_user_logged_in()){
| |
| 4210 | global $wp_version; | |
| 4211 | if ( version_compare( $wp_version, '4.4', '>=' ) ) {
| |
| 4212 | add_filter('comment_form_fields','flo_crowd_comment_form_fields',50, 1);
| |
| 4213 | } | |
| 4214 | ||
| 4215 | } | |
| 4216 | function flo_crowd_comment_form_fields($comment_fields){//deb::e($comment_fields);
| |
| 4217 | ||
| 4218 | $new_comment_fields = array( | |
| 4219 | $comment_fields['author'], | |
| 4220 | $comment_fields['email'], | |
| 4221 | $comment_fields['url'], | |
| 4222 | $comment_fields['comment'] | |
| 4223 | ); | |
| 4224 | ||
| 4225 | return $new_comment_fields; | |
| 4226 | } | |
| 4227 | ||
| 4228 | // Add custom css for the full width sliders containers | |
| 4229 | add_action('wp_head', 'flo_get_custom_css_slider_height');
| |
| 4230 | function flo_get_custom_css_slider_height(){
| |
| 4231 | ||
| 4232 | $page_slyder_info = flo_get_page_slyder_info(); | |
| 4233 | ||
| 4234 | // if the we have a slideshow on the current page and if it is a full width slideshow | |
| 4235 | if($page_slyder_info['selected_slider_id'] > 0 && $page_slyder_info['slideshow_type'] != 'content_width'){
| |
| 4236 | ||
| 4237 | $slides_image_size = array('content_width' => 'slideshow',
| |
| 4238 | 'simple_full_width' => 'slideshowfullwidth', | |
| 4239 | 'visible_near_by' => 'slideshowvisiblenearby', | |
| 4240 | 'full_screen' => 'slideshowfullscreen', | |
| 4241 | 'slick' => 'slideshowvisiblenearby', | |
| 4242 | ); | |
| 4243 | ||
| 4244 | $height_option_name = $slides_image_size[$page_slyder_info['slideshow_type'] ]; | |
| 4245 | ||
| 4246 | $slider_height = options::get_value('sliders', $height_option_name.'_height');
| |
| 4247 | ||
| 4248 | if(!is_numeric($slider_height)){
| |
| 4249 | $slider_height = 500; | |
| 4250 | } | |
| 4251 | ||
| 4252 | if($page_slyder_info['slideshow_type'] == 'visible_near_by'){
| |
| 4253 | $nearby_width_option_name = $slides_image_size[$page_slyder_info['slideshow_type'] ].'_width'; | |
| 4254 | $nearby_width = options::get_value('sliders', $nearby_width_option_name);
| |
| 4255 | ||
| 4256 | if(!is_numeric($nearby_width)){
| |
| 4257 | $nearby_width = 400; | |
| 4258 | } | |
| 4259 | } | |
| 4260 | ||
| 4261 | ||
| 4262 | $full_width_slideshow_mobile_height = options::get_value('sliders', 'full_width_slideshow_mobile_height');
| |
| 4263 | ||
| 4264 | $visible_nearby_gutter = options::get_value('sliders', 'visible_nearby_gutter');
| |
| 4265 | if(is_numeric($visible_nearby_gutter)){
| |
| 4266 | $visible_nearby_gutter = $visible_nearby_gutter/2; | |
| 4267 | } | |
| 4268 | ||
| 4269 | ||
| 4270 | ?> | |
| 4271 | ||
| 4272 | <style> | |
| 4273 | <?php | |
| 4274 | $media = false; | |
| 4275 | if(is_numeric($full_width_slideshow_mobile_height)){
| |
| 4276 | $media = true; | |
| 4277 | ?> | |
| 4278 | .crowd-full{
| |
| 4279 | height: <?php echo $full_width_slideshow_mobile_height; ?>px; | |
| 4280 | } | |
| 4281 | ||
| 4282 | <?php | |
| 4283 | } else if ( ! empty($full_width_slideshow_mobile_height) && strpos($full_width_slideshow_mobile_height, 'vh') !== false ) {
| |
| 4284 | $media = true; | |
| 4285 | ?> | |
| 4286 | .crowd-full{
| |
| 4287 | height: <?php echo $full_width_slideshow_mobile_height; ?>; | |
| 4288 | } | |
| 4289 | ||
| 4290 | ||
| 4291 | <?php | |
| 4292 | } | |
| 4293 | if ($media) { ?>
| |
| 4294 | @media only screen and (max-width: 640px) {
| |
| 4295 | ||
| 4296 | .crowd-full .main-slideshow .royalSlider {
| |
| 4297 | height: 100% !important; | |
| 4298 | } | |
| 4299 | ||
| 4300 | .crowd-full .main-slideshow .royalSlider > div {
| |
| 4301 | height: 100% !important; | |
| 4302 | } | |
| 4303 | ||
| 4304 | } | |
| 4305 | <?php } | |
| 4306 | ?> | |
| 4307 | ||
| 4308 | @media only screen and (min-width: 641px) {
| |
| 4309 | .crowd-full-width .crowd-push, .crowd-full-width .crowd-full{
| |
| 4310 | height: <?php echo $slider_height; ?>px; | |
| 4311 | } | |
| 4312 | <?php | |
| 4313 | if(is_numeric($visible_nearby_gutter)) { ?>
| |
| 4314 | .crowd-nearby-slider .rsSlide{
| |
| 4315 | padding: 0 <?php echo $visible_nearby_gutter; ?>px; | |
| 4316 | } | |
| 4317 | <?php } ?> | |
| 4318 | ||
| 4319 | <?php | |
| 4320 | $slick_slideshow_height = options::get_value('sliders','slideshowvisiblenearby_height');
| |
| 4321 | ||
| 4322 | if( is_numeric($slick_slideshow_height) ){
| |
| 4323 | ?> | |
| 4324 | .main-slideshow .flo-slick-slider{
| |
| 4325 | height: <?php echo $slick_slideshow_height; ?>px; | |
| 4326 | } | |
| 4327 | <?php | |
| 4328 | } | |
| 4329 | ?> | |
| 4330 | ||
| 4331 | } | |
| 4332 | ||
| 4333 | <?php | |
| 4334 | if($page_slyder_info['slideshow_type'] == 'visible_near_by'){
| |
| 4335 | ?> | |
| 4336 | .main-slideshow .crowd-nearby-slider{
| |
| 4337 | max-width: <?php echo $nearby_width ?>px; | |
| 4338 | } | |
| 4339 | <?php | |
| 4340 | } | |
| 4341 | ||
| 4342 | ||
| 4343 | ?> | |
| 4344 | ||
| 4345 | ||
| 4346 | </style> | |
| 4347 | <?php | |
| 4348 | ||
| 4349 | ||
| 4350 | } | |
| 4351 | ||
| 4352 | } | |
| 4353 | ||
| 4354 | ||
| 4355 | // use 'hentry' class only on single blog posts | |
| 4356 | function flo_remove_hentry( $classes ) {
| |
| 4357 | global $post; | |
| 4358 | //var_dump(in_array(get_post_type( $post ), array('video','gallery')));
| |
| 4359 | if ( !(get_post_type( $post ) == 'post' && is_single()) ) {
| |
| 4360 | $classes = array_diff( $classes, array( 'hentry' ) ); | |
| 4361 | } | |
| 4362 | return $classes; | |
| 4363 | } | |
| 4364 | add_filter( 'post_class','flo_remove_hentry' ); | |
| 4365 | ||
| 4366 | // the maximum image width to be included in a srcset attribute will be the image width | |
| 4367 | // default is 1600 | |
| 4368 | if(!function_exists('flo_custom_max_srcset_image_width')){
| |
| 4369 | function flo_custom_max_srcset_image_width( $max_width, $size_array ) {
| |
| 4370 | $width = $size_array[0]; | |
| 4371 | ||
| 4372 | // set the max image width the value of the this image width | |
| 4373 | return $width; | |
| 4374 | } | |
| 4375 | } | |
| 4376 | ||
| 4377 | if(!function_exists('flo_disable_max_srcset_image_width')){
| |
| 4378 | function flo_disable_max_srcset_image_width() {
| |
| 4379 | return 1; | |
| 4380 | } | |
| 4381 | } | |
| 4382 | ||
| 4383 | ?> | |
| 4384 | <?php | |
| 4385 | if(!function_exists('flo_create_image_srcset')){
| |
| 4386 | function flo_create_image_srcset($size_array,$image_meta, $original_img_url, $crop = false){
| |
| 4387 | $image_width = $image_meta['width']; | |
| 4388 | $image_height = $image_meta['height']; | |
| 4389 | $srcset = ''; | |
| 4390 | $srcset_array = array(); | |
| 4391 | if(is_array($size_array) && sizeof($size_array)){
| |
| 4392 | ||
| 4393 | foreach ($size_array as $srcset_dimensions) {
| |
| 4394 | ||
| 4395 | if(isset( $srcset_dimensions['resize_method'])){
| |
| 4396 | $resize_method = $srcset_dimensions['resize_method']; | |
| 4397 | }else{
| |
| 4398 | $resize_method = 'width_base'; // the default | |
| 4399 | } | |
| 4400 | if( ($resize_method == 'width_base' && $image_width > $srcset_dimensions['width']) || | |
| 4401 | ($resize_method == 'height_base' && $image_height > $srcset_dimensions['height']) | |
| 4402 | ||
| 4403 | ){
| |
| 4404 | $srcset_img_url = aq_resize($original_img_url, $srcset_dimensions['width'], $srcset_dimensions['height'], $crop, false); | |
| 4405 | if(is_array($srcset_img_url) && isset($srcset_img_url[0]) && strlen($srcset_img_url[0])){
| |
| 4406 | if(isset($srcset_dimensions['srcset_width'])){
| |
| 4407 | $srcset_width = $srcset_dimensions['srcset_width']; | |
| 4408 | if(!strstr($srcset_width,'x')){
| |
| 4409 | $srcset_width .= 'w'; | |
| 4410 | } | |
| 4411 | }else{
| |
| 4412 | $srcset_width = $srcset_img_url[1].'w'; | |
| 4413 | } | |
| 4414 | ||
| 4415 | $srcset_array[] = $srcset_img_url[0] .' '.$srcset_width; | |
| 4416 | } | |
| 4417 | ||
| 4418 | }else if(!in_array($original_img_url .' '.$image_width.'w',$srcset_array)){
| |
| 4419 | $srcset_array[] = $original_img_url .' '.$image_width.'w'; | |
| 4420 | } | |
| 4421 | } | |
| 4422 | ||
| 4423 | //$srcset_array[] = $original_img_url .' '.$image_width.'w'; | |
| 4424 | } | |
| 4425 | ||
| 4426 | if(sizeof($srcset_array)){
| |
| 4427 | $srcset = implode(', ', $srcset_array);
| |
| 4428 | } | |
| 4429 | ||
| 4430 | return $srcset; | |
| 4431 | } | |
| 4432 | } | |
| 4433 | ||
| 4434 | /** | |
| 4435 | * | |
| 4436 | * Function that renders the top dashboard link | |
| 4437 | * http://i.imgur.com/k7BxRME.png | |
| 4438 | */ | |
| 4439 | if(!function_exists('flo_render_dashboard_top_bar')){
| |
| 4440 | function flo_render_dashboard_top_bar(){
| |
| 4441 | ob_start(); | |
| 4442 | ob_clean(); | |
| 4443 | ?> | |
| 4444 | <div class="flo-dashboard-top"> | |
| 4445 | <ul> | |
| 4446 | <li class="doc"><a href="<?php echo _FLO_DOCS_; ?>" target="_blank"><?php _e('Documentation','flotheme') ?></a></li>
| |
| 4447 | <!-- <li class="manage"><a href="admin.php?page=_flo_options&tab=16"><?php _e('Manage','flotheme') ?></a></li> -->
| |
| 4448 | <li class="updated"><a href="admin.php?page=flotheme_updater"><?php _e('Updates','flotheme') ?></a></li>
| |
| 4449 | <li class="news"><a href="<?php echo _FLO_NEWS_; ?>" target="_blank" ><?php _e('News','flotheme') ?></a></li>
| |
| 4450 | <li class="support"><a href="<?php echo _FLO_SUPPORT_; ?>" target="_blank"><?php _e('Support','flotheme') ?></a></li>
| |
| 4451 | </ul> | |
| 4452 | </div> | |
| 4453 | <?php | |
| 4454 | $top_dashboard = ob_get_clean(); | |
| 4455 | ||
| 4456 | return $top_dashboard; | |
| 4457 | } | |
| 4458 | } | |
| 4459 | ||
| 4460 | /** | |
| 4461 | * @since 2.3 | |
| 4462 | * | |
| 4463 | * Previously the tiles for single blog posts and pages were | |
| 4464 | * using H2s, and we decided to change them to H1s | |
| 4465 | * The following function will update thw H1 typography settings to what | |
| 4466 | * was used for H2s to not have visual changes on the site when user | |
| 4467 | * updates the theme. | |
| 4468 | * Normaly that update should run just once | |
| 4469 | * | |
| 4470 | */ | |
| 4471 | add_action('init', 'flo_migrate_h2_to_h1');
| |
| 4472 | if(!function_exists('flo_migrate_h2_to_h1')){
| |
| 4473 | function flo_migrate_h2_to_h1(){
| |
| 4474 | ||
| 4475 | if(!get_option('flo_h1_updated')){
| |
| 4476 | $ct = wp_get_theme(); | |
| 4477 | if(isset($ct->version) && $ct->version < 2.4){ // we will run this only till version 2.4
| |
| 4478 | //deb::e(get_option('typography'));
| |
| 4479 | ||
| 4480 | $flo_typography = get_option('typography');
| |
| 4481 | ||
| 4482 | if($flo_typography){ // if the options are defined
| |
| 4483 | // we want to have H1 using the same font as H2 | |
| 4484 | ||
| 4485 | //font_font_family | |
| 4486 | if(isset($flo_typography['h2_font_font_family'])){
| |
| 4487 | $flo_typography['h1_font_font_family'] = $flo_typography['h2_font_font_family']; | |
| 4488 | } | |
| 4489 | ||
| 4490 | //font_font_weight | |
| 4491 | if(isset($flo_typography['h2_font_font_weight'])){
| |
| 4492 | $flo_typography['h1_font_font_weight'] = $flo_typography['h2_font_font_weight']; | |
| 4493 | } | |
| 4494 | ||
| 4495 | //font_font_style | |
| 4496 | if(isset($flo_typography['h2_font_font_style'])){
| |
| 4497 | $flo_typography['h1_font_font_style'] = $flo_typography['h2_font_font_style']; | |
| 4498 | } | |
| 4499 | ||
| 4500 | //font_font_size | |
| 4501 | if(isset($flo_typography['h2_font_font_size'])){
| |
| 4502 | $flo_typography['h1_font_font_size'] = $flo_typography['h2_font_font_size']; | |
| 4503 | } | |
| 4504 | ||
| 4505 | //font_font_size_mobile | |
| 4506 | if(isset($flo_typography['h2_font_font_size_mobile'])){
| |
| 4507 | $flo_typography['h1_font_font_size_mobile'] = $flo_typography['h2_font_font_size_mobile']; | |
| 4508 | } | |
| 4509 | ||
| 4510 | //font_font_letter_spacing | |
| 4511 | if(isset($flo_typography['h2_font_font_letter_spacing'])){
| |
| 4512 | $flo_typography['h1_font_font_letter_spacing'] = $flo_typography['h2_font_font_letter_spacing']; | |
| 4513 | } | |
| 4514 | ||
| 4515 | //font_font_letter_spacing_mobile | |
| 4516 | if(isset($flo_typography['h2_font_font_letter_spacing_mobile'])){
| |
| 4517 | $flo_typography['h1_font_font_letter_spacing_mobile'] = $flo_typography['h2_font_font_letter_spacing_mobile']; | |
| 4518 | } | |
| 4519 | ||
| 4520 | //update the theme h1 options | |
| 4521 | update_option('typography',$flo_typography);
| |
| 4522 | } | |
| 4523 | ||
| 4524 | update_option('flo_h1_updated','1');
| |
| 4525 | } | |
| 4526 | } | |
| 4527 | ||
| 4528 | } | |
| 4529 | } | |
| 4530 | ||
| 4531 | /** | |
| 4532 | * | |
| 4533 | * Try to retrieve the change log from flothemes.com | |
| 4534 | * if that is not possible for some reason, we just read the change log file | |
| 4535 | * @params string t_n theme name | |
| 4536 | */ | |
| 4537 | if(!function_exists('flo_get_change_log')){
| |
| 4538 | function flo_get_change_log($t_n = _TN_){
| |
| 4539 | $transient_name = $t_n.'_change-remote-log'; | |
| 4540 | ||
| 4541 | //delete_transient($transient_name ); | |
| 4542 | ||
| 4543 | if ( FALSE == $response = get_transient( $transient_name ) ) {
| |
| 4544 | ||
| 4545 | $theme_name = strtolower($t_n); | |
| 4546 | $url = 'https://flothemes.com/themes/'.$theme_name.'/?change_log=1'; | |
| 4547 | $args = array( | |
| 4548 | 'sslverify' => false, | |
| 4549 | ); | |
| 4550 | ||
| 4551 | $response = wp_remote_get( $url, $args ); | |
| 4552 | ||
| 4553 | set_transient( $transient_name, $response, 60 * 60 * 24 ); // 1 day | |
| 4554 | } | |
| 4555 | ||
| 4556 | //for debugging purpuses | |
| 4557 | if(isset($_GET['flo_debug_change_log']) && $_GET['flo_debug_change_log'] == 1){
| |
| 4558 | echo '<pre>'; | |
| 4559 | var_dump($response); | |
| 4560 | echo '</pre>'; | |
| 4561 | die(); | |
| 4562 | } | |
| 4563 | ||
| 4564 | if (is_wp_error($response) || $response['response']['code'] != '200' || !isset($response['body']) || strpos($response['body'], 'container main-header') ) {
| |
| 4565 | // in case something went wrong retrieving the log from our server, | |
| 4566 | // then we just load if from the change log file available in the theme. | |
| 4567 | return flo_get_change_log_from_file(); | |
| 4568 | } | |
| 4569 | ||
| 4570 | $result = $response['body']; | |
| 4571 | ||
| 4572 | return $result; | |
| 4573 | ||
| 4574 | } | |
| 4575 | ||
| 4576 | } | |
| 4577 | ||
| 4578 | if(!function_exists('flo_get_change_log_from_file')){
| |
| 4579 | function flo_get_change_log_from_file(){
| |
| 4580 | global $wp_filesystem; | |
| 4581 | // Initialize the WP filesystem, no more using 'file-put-contents' function | |
| 4582 | if (empty($wp_filesystem)) {
| |
| 4583 | require_once (ABSPATH . '/wp-admin/includes/file.php'); | |
| 4584 | WP_Filesystem(); | |
| 4585 | } | |
| 4586 | $change_log_abs_file_path = get_stylesheet_directory().'/change-log.txt'; | |
| 4587 | ||
| 4588 | // read the change log file; | |
| 4589 | $change_log_content = $wp_filesystem->get_contents($change_log_abs_file_path); | |
| 4590 | ||
| 4591 | return nl2br($change_log_content) ; | |
| 4592 | } | |
| 4593 | } | |
| 4594 | ?> |